场景:自己封装的插件需要点击子组件的按钮去操作父组件的数据
方法
子组件代码
1 | <template> |
父组件
1 | <template> |
拓展:vue emit 有多个参数该如何写
1 | this.$emit('transferName', {name: this.name, dev: this.des}) |
父组件
HTML代码
1 | <child @transferName="getNameAndDes">child> |
JS代码
1 | getNameAndDes(msg) { |
转载请保持原始链接
场景:自己封装的插件需要点击子组件的按钮去操作父组件的数据
方法
子组件代码
1 | <template> |
父组件
1 | <template> |
拓展:vue emit 有多个参数该如何写
1 | this.$emit('transferName', {name: this.name, dev: this.des}) |
父组件
HTML代码
1 | <child @transferName="getNameAndDes">child> |
JS代码
1 | getNameAndDes(msg) { |
转载请保持原始链接