How can the actions of Vue's children (grandchildren) trigger directly to grandparent (or more) components? Does vue3.0 have a similar way to $parent?
What problem does this feature solve?
。
What does the proposed API look like?
How to make the events of el-form-item component pay directly to the el-form component。
I hope there's something like this: this.dispatch('ElFormItem', 'el.form.blur', [this.value]); ...
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));
}
},