1.全局事件总线$bus配置:
Vue.prototype.$event = this;
// moduleA.vue // 发送数据
methods: {
sendData () {
// 通过修改Vue原型链的方式注册
this.$event.$emit('sendSata', "冬雨");
// 直接注册在window上
}
moduleB.vue //接受数据
mounted(){
this.$event.$on('sendSata', data=>{
this.name = data;
}