You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
380 B
14 lines
380 B
export function getParent(name, context) {
|
|
let parent = context.$parent;
|
|
// 通过while历遍,这里主要是为了H5需要多层解析的问题
|
|
while (parent) {
|
|
// 父组件
|
|
if (parent.$options && parent.$options.name !== name) {
|
|
// 如果组件的name不相等,继续上一级寻找
|
|
parent = parent.$parent;
|
|
} else {
|
|
return parent;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|