非父子组件传递事件常用方案
// main.js
const BUS = new Vue()
Vue.prototype.BUS = BUS
// A.vue
this.BUS.$emit('changeSidebar') // changeSidebar和$on处一致即可
// B.vue
mounted () {
this.BUS.$on('changeSidebar', () => {
this.isCollapse = !this.isCollapse
})
}