//定义组件
Vue.component(‘father‘,{
template:‘#father‘,
data(){
return {//用来接受子组件给的数据
shou:0
}
},
methods:{//在父组件中定义事件处理程序方法 然后将父组件的方法已自定义的形式绑定在子组件身上 son
fn(da){//接受子组件参数
this.shou=da
}
}
})
Vue.component(‘son‘,{
template:‘#son‘,
data(){//先子组件的数据
return {
money:5000
}
},
methods:{
givehongbao(){
this.$emit(‘give‘,this.money)
//通过this.$emit 发送两个参数 参数1 自定义的那个方法名give 参数2子组件传的数据 money
}
}
})