這裏的child-say 是指定的不能更改this
父組件code
<component-a v-on:child-say="listenToMyBoy"></component-a> <p>Do you like me? {{childWords}}</p> methods: { listenToMyBoy: function (somedata){ this.childWords = somedata } }
子組件component
<button v-on:click="onClickMe">like!</button> methods: { onClickMe: function(){ this.$emit('child-say',this.somedata); } }