vue 获取父组件
2020-07-10 本文已影响0人
Amy_yqh
dispatch(componentName, eventName, params) {
var parent = this.$parent || this.$root
var name = parent.$options.componentName
while (parent && (!name || name !== componentName)) {
parent = parent.$parent
if (parent) {
name = parent.$options.componentName
}
}
if (parent) {
parent.$emit.apply(parent, [eventName].concat(params))
}
}
this.dispatch('MagicCheckboxGroup', 'change', [this._checkboxGroup.value])