vue的eventBus

首先在main.js中

Vue.prototype.$eventBus = new Vue()

A组件中通过触发事件或者其他什么,然后发射数据

this.$eventBus.$emit('key','data-1232131232132131232');

B组件中接收A组件的数据

this.$eventBus.$on('key',function(params){ console.log(params); // data-1232131232132131232 });
原文地址:https://www.cnblogs.com/1rookie/p/8568744.html