Vue1.0组件间传递
使用$on()监听事件;
使用$emit()在它上面触发事件;
使用$dispatch()派发事件,事件沿着父链冒泡;
使用$broadcast()广播事件,事件向下传导给所有的后代
Vue2.0后$dispatch(),$broadcast()被弃用,见https://cn.vuejs.org/v2/guide/migration.html#dispatch-和-broadcast-替换
1.子组件向父组件的传值:
Child.vue
子组件
parent.vue
父组件
2.父组件向子组件传值
parent.vue
父组件
child.vue
子组件
子组件显示信息:{{parentToChild}}
3.采用eventBus.js传值---兄弟组件间的传值
eventBus.js
import Vue from 'Vue' export default new Vue()
App.vue
FirstChild.vue
{{message}}
SecondChild.vue
{{message}}









