1、新建bus.js
import Vue from 'vue'
// 使用 Event Bus
const bus = new Vue()
export default bus
2、main.js引用
import bus from '@/libs/bus'
Vue.prototype.$bus = bus
3、被调用组件 this.getList()方法
created() {
this.$nextTick(()=>{
this.$bus.$on("getList", () => {this.getList()})
})
},
4、调用组件
this.$bus.$emit('getList')