optimize Select event broadcast
optimize Select event broadcast
This commit is contained in:
parent
04e5e3cd29
commit
a9131058ab
3 changed files with 48 additions and 6 deletions
|
@ -183,4 +183,33 @@ function findComponentUpward (content, componentName, componentNames) {
|
|||
}
|
||||
return parent;
|
||||
}
|
||||
export {findComponentUpward};
|
||||
export {findComponentUpward};
|
||||
|
||||
// Find components downward
|
||||
function findComponentDownward (content, componentName) {
|
||||
let childrens = content.$children;
|
||||
let children = null;
|
||||
|
||||
if (childrens.length) {
|
||||
childrens.forEach(child => {
|
||||
const name = child.$options.name;
|
||||
if (name === componentName) {
|
||||
children = child;
|
||||
}
|
||||
});
|
||||
|
||||
for (let i = 0; i < childrens.length; i++) {
|
||||
const child = childrens[i];
|
||||
const name = child.$options.name;
|
||||
if (name === componentName) {
|
||||
children = child;
|
||||
break;
|
||||
} else {
|
||||
children = findComponentDownward(child, componentName);
|
||||
if (children) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
export {findComponentDownward};
|
Loading…
Add table
Add a link
Reference in a new issue