vue js 组件之间的通信($emit $on)

//注册一个空的实例,作为中转站。

// 注册一个空的 Vue 实例,作为 ‘中转站’
var eventBus = new Vue({});

//$.emit触发事件传值 $.on监听事件接受值

//eventBus就是中转站  $emit 和 $on 的第一个参数相对应的 就能进行通信。

eventBus.$emit('refreshView', this.xmlObj);

posted @ 2017-03-31 17:18  一本小神虾  阅读(3655)  评论(0)    收藏  举报