Commit d2efebcb authored by Leopoldthecoder's avatar Leopoldthecoder Committed by 杨奕

fix getPropByPath error

parent 4b3edc13
...@@ -49,6 +49,7 @@ export function getPropByPath(obj, path, strict) { ...@@ -49,6 +49,7 @@ export function getPropByPath(obj, path, strict) {
let keyArr = path.split('.'); let keyArr = path.split('.');
let i = 0; let i = 0;
for (let len = keyArr.length; i < len - 1; ++i) { for (let len = keyArr.length; i < len - 1; ++i) {
if (!tempObj && !strict) break;
let key = keyArr[i]; let key = keyArr[i];
if (key in tempObj) { if (key in tempObj) {
tempObj = tempObj[key]; tempObj = tempObj[key];
...@@ -62,7 +63,7 @@ export function getPropByPath(obj, path, strict) { ...@@ -62,7 +63,7 @@ export function getPropByPath(obj, path, strict) {
return { return {
o: tempObj, o: tempObj,
k: keyArr[i], k: keyArr[i],
v: tempObj[keyArr[i]] v: tempObj ? tempObj[keyArr[i]] : null
}; };
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment