Vue 子组件向父组件传值

这里的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);
      }
    }
相关文章
相关标签/搜索