在 main.JS 中写上:
- new vue({
- router,
- store,
- render:h=>h(App),
- data:{
- eventBus:new Vue()
- }
- }).$mount('#App)
在组件中事件传递
- this.$root.eventBus.$emit('事件名','参数')// 传递
- this.$root.eventBus.$on('事件名',callBack)// 事件处理
来源: http://www.qdfuns.com/article/51759/76e1bbc12914915d1cdb6bab846967fe.html