I have
<component-one></component-one>
<component-two></component-two>
<component-three></component-three>
A component two
contains a component three
.
I am currently in an emit
event to <component-one>
be found in <component-three>
.
Q <component-one>
I fire the event as follows:
this.$bus.$emit('setSecondBanner', finalBanner);
Then in <component-three>
I catch him like this:
mounted() {
this.$bus.$on('setSecondBanner', (banner) => {
alert('Caught');
this.banner = banner;
});
},
But the event never caught
!
I define a bus like this (in my core.js):
let eventBus = new Vue();
Object.defineProperties(Vue.prototype, {
$bus: {
get: () => { return eventBus; }
}
});
What could be wrong here? When I check vue-dev-tools
, I see that the event was fired!
source
share