vue 子组件像父组件传递数据

1.

       使用 $on(eventName) 监听事件

       使用 $emit(eventName) 触发事件

2.  父组件  

  父组件

<div class="parent">
<child v-on:increment="get"></child>
</div>


子组件
<span @click="returns">返回</span>

子组件中

export default {
data () {
return {
hides: false
}
},
methods: {
returns: function () {
this.hides = false
this.$emit('increment', this.hides)
}
}
}

父组件

export default {
data () {
return {
shows: false
}
},
methods: {
get (msg) {
this.shows = msg
}
}
}



原文地址:https://www.cnblogs.com/dengxiaolei/p/7411145.html