0
点赞
收藏
分享

微信扫一扫

vue子组件向父组件传值


父组件:

<child ref="xxx"></child>

methods: {
test(value){
},
},
mounted() {
this.$refs.xxx.$on('haha', this.test);
}

也可以这么写

<child @haha="test"></child>

methods: {
test(value){

},
}

子组件:

<button @click="send(value)"></button>

send(value) {
this.$emit('haha',value);
}


举报

相关推荐

0 条评论