子组件 <template> <div @click="open"></div> </template>this
methods: { open() { this.$emit('showbox','the msg'); //触发showbox方法,'the msg'为向父组件传递的数据 } } 父组件 <child @showbox="toshow" :msg="msg"></child> //监听子组件触发的showbox事件,而后调用toshow方法事件
methods: { toshow(msg) { this.msg = msg; } }it