const bus = function(Vue){
const Bus = new Vue({
methods:{
emit(event,...args){
this.$emit(event,...args);
},
on(event,callback){
this.$on(event,callback);
},
off(event,callback){
this.$off(event,callback);
}
}
})
Vue.prototype.$bus=Bus;
}
export default bus;
单独创建一个bus.js文件,然后在使用的地方引入在调用