make menu support more than 2 levels

This commit is contained in:
zhigang.li 2018-01-15 13:17:58 +08:00
parent 3537176f98
commit 4bce764525
7 changed files with 117 additions and 48 deletions

View file

@ -217,6 +217,17 @@ export function findComponentsDownward (context, componentName) {
}, []);
}
// Find components upward
export function findComponentsUpward (context, componentName) {
let parents = [];
if (context.$parent) {
if (context.$parent.$options.name === componentName) parents.push(context.$parent);
return parents.concat(findComponentsUpward(context.$parent, componentName));
} else {
return [];
}
}
/* istanbul ignore next */
const trim = function(string) {
return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');