mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-03 03:38:41 +08:00
feat(utils): getPropByPath function adjust (#1276)
Co-authored-by: 三咲智子 <sxzz@sxzz.moe>
This commit is contained in:
parent
00d38e1807
commit
4d3a499fa6
@ -49,6 +49,12 @@ export function getPropByPath(
|
||||
v: Nullable<unknown>
|
||||
} {
|
||||
let tempObj = obj
|
||||
let key, value
|
||||
|
||||
if (obj && hasOwn(obj, path)) {
|
||||
key = path
|
||||
value = tempObj?.[path]
|
||||
} else {
|
||||
path = path.replace(/\[(\w+)\]/g, '.$1')
|
||||
path = path.replace(/^\./, '')
|
||||
|
||||
@ -67,10 +73,13 @@ export function getPropByPath(
|
||||
break
|
||||
}
|
||||
}
|
||||
key = keyArr[i]
|
||||
value = tempObj?.[keyArr[i]]
|
||||
}
|
||||
return {
|
||||
o: tempObj,
|
||||
k: keyArr[i],
|
||||
v: tempObj?.[keyArr[i]],
|
||||
k: key,
|
||||
v: value,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user