update RadioGroup

update RadioGroup
This commit is contained in:
梁灏 2017-03-15 17:44:19 +08:00
parent 4f5d393734
commit 3f281d6ce0
4 changed files with 62 additions and 42 deletions

View file

@ -185,9 +185,9 @@ function findComponentUpward (content, componentName, componentNames) {
}
export {findComponentUpward};
// Find components downward
// Find component downward
function findComponentDownward (content, componentName) {
let childrens = content.$children;
const childrens = content.$children;
let children = null;
if (childrens.length) {
@ -212,4 +212,24 @@ function findComponentDownward (content, componentName) {
}
return children;
}
export {findComponentDownward};
export {findComponentDownward};
// Find components downward
function findComponentsDownward (content, componentName, components = []) {
const childrens = content.$children;
if (childrens.length) {
childrens.forEach(child => {
const name = child.$options.name;
const childs = child.$children;
if (name === componentName) components.push(child);
if (childs.length) {
const findChilds = findComponentsDownward(child, componentName, components);
if (findChilds) components.concat(findChilds);
}
});
}
return components;
}
export {findComponentsDownward};