vue-bus 可以实现
//安装: npm install vue-bus
//在main.js 中引入vuebus:
import Vue from 'vue';import VueBus from 'vue-bus'; Vue.use(VueBus);
//在组件中使用
//触发事件:
this.$bus.emit("onslected",params)
//应对事件:
mounted:function(){
this.$bus.on("onslected",function(){
});
},
destroyed:function(){
this.$bus.off("onslected");
}
请采纳
同问,解决了吗?怎么传