本文共 545 字,大约阅读时间需要 1 分钟。
子组件:
export default { mounted: function () { this.$nextTick(function () { this.$on('childMethod', function () { console.log('监听成功') }) }) }, methods { callMethod () { console.log('调用成功') } }}
父组件:
export default { methods: { click () { this.$refs.child.$emit('childMethod') // 方法1 this.$refs.child.callMethod() // 方法2 }, components: { child: child }}
转载地址:http://bcfnb.baihongyu.com/