Vue组件通信子组件传值给父组件主要通过$emit
给子组件绑定一个事件
//子组件 @事件名=‘函数’ <child @children='fn'></child> //在子组件methods选项卡中添加事件 methods:{ fn(){
//this.$emit('父组件绑定事件名',值) this.$emit(‘father’,value) } }
在父组件中给子组件标签绑定事件
<father>
<!--> <child @事件名=‘函数’ </--> <child @father='father'></child> <father> //父组件methods选项卡中用定义的函数实现传值 methods:{
//事件名(值){} father(valuue){ this.father=this.value } }