vue子父组件的通信
Element使用的是Vue2.0版本,众所周知在Vue 1.0升级到2.0中去除了$broadcast和$dispatch方法。
1、父组件向子组件传值
a、app.vue父组件
"app">{{title}}
"title">
"title">
"text" v-model="newItem" v-on:keyup.enter="addNew">
- for="item in items" v-bind:class="{finished:item.isFinished}" v-on:click="toggleFinish(item)"> {{item.label}}
b、componentA.vue子组件
<class="hello">{{msg}}
{{msgfromfather}}
c、效果
2、子组件向父组件传值
a、app.vue父组件
"app">{{title}}
"title">
"title">
"text" v-model="newItem" v-on:keyup.enter="addNew">
- for="item in items" v-bind:class="{finished:item.isFinished}" v-on:click="toggleFinish(item)"> {{item.label}}
child tells me:{{childwords}}
b、componentA.vue子组件
<class="hello">{{msg}}
{{msgfromfather}}