// 这里的 v-on 就相当于是$on, child-say = 监控的方法名,
// listenToMyBoy = callback
Do you like me? {{childsay}}
methods: {
listenToMyBoy: function (data){ //data 就是从子组件接收到的值
this.childsay = data
}
}
// vm.$emit("父组件监控的方法名",要传给父组件的参数)
// 这里的 talk 只是为了触发 emit()
<button v-on:click="talk"> I like you </button>
methods: {
talk: function(){
this.$emit('childsay',想要传给父组件的数据data);
}
}
No comments:
Post a Comment