vant/packages/mixins/find-parent.js
2019-02-19 16:04:29 +08:00

25 lines
381 B
JavaScript

/**
* find parent component by name
*/
export const FindParentMixin = {
data() {
return {
parent: null
};
},
methods: {
findParent(name) {
let parent = this.$parent;
while (parent) {
if (parent.$options.name === name) {
this.parent = parent;
break;
}
parent = parent.$parent;
}
}
}
};