Values are passed between child components
An EventBus is called an EventBus
$emit(” Event name “, “parameters”)——– sends events
$ON (” Event name “, “Receive Parameter”)——- Receives events
$EventBus = new Vue(); $EventBus = new Vue()
1 Create an eventbus.js file under SRC
2 is used in child component 1
import eventBus from '.. /.. /assets/js/eventBus'
export default {
methods: {selectSymbol(data) {
eventBus.$emit('sym',data.symbol)
}
}
}
Copy the code
3 is used in child component 2
import eventBus from '.. /.. /assets/js/eventBus'
export default {
created(){
eventBus.$on('sym'.(symbolOne) = > {
let _this = this
if (symbolOne) {
_this.symbol = symbolOne
}
})
}
}
Copy the code