current position:Home>Vue eventbus value transfer between brother components

Vue eventbus value transfer between brother components

2022-06-24 09:50:54Time202051

main.js Entrance file

Vue.prototype.$EventBus = new Vue();

towards EventBus insert data

this.$EventBus.$emit('dataB', this.dataB)

consumption eventBus data

this.$EventBus.$on('dataB', (res) => {
    
     this.dataA = res
})

beforeDestory Medium destruction

this.$EventBus.$off('dataB');

copyright notice
author[Time202051],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/175/202206240903259859.html

Random recommended