vue 子组件向父组件传值

时间:2017-12-06 17:19:37   收藏:0   阅读:212
父组件这么写
<component-a  v-on:child-say="listenToMyBoy"></component-a>

<p>Do you like me? {{childWords}}</p>

 methods: {

            listenToMyBoy: function (somedata){

              this.childWords = somedata

            }

        }

 

子组件component-a这么写

<button v-on:click="onClickMe">like!</button>

 

methods: {

      onClickMe: function(){

        this.$emit(child-say,this.somedata);

      }

 

原文:http://www.cnblogs.com/wangzhichao/p/7993163.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!