创建一个event-bus.js
import Vue from 'vue'
export const EventBus =new Vue();
//在asss.vue触发监听
import {EventBus} from './event-bus'
tapSend(){
EventBus.$emit('share')
}
在bsss.vue引入eventBus 在mounted里监听
import {EventBus } from './event-bus'
mounted(){
EventBus.$on('share',()=>{console.log('触发了')}
})
要在beforeDestory中解绑
beforeDestory(){
EventBus.$off('share')
}