1.创建一个vue实例
bus.js
import Vue from 'vue'
export default new Vue()
a.vue
import Bus from '@/libs/bus.js'
Bus.$emit('selectionSampleList', this.selection)
b.vue
import Bus from '@/libs/bus.js'
mounted() {
this.init()
Bus.$on('selectionSampleList', (e) => {
this.$refs['sampleDetail'].init(e)
})
},
activated () {
Bus.$on('selectionSampleList', (e) => {
this.$refs['sampleDetail'].init(e)
})
},