make menu support more than 2 levels
This commit is contained in:
parent
3537176f98
commit
4bce764525
7 changed files with 117 additions and 48 deletions
|
@ -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, '');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue