I have a component which triggers this.$root.$emit('some-root-event')
like
clickHandler: function() {
this.$root.$emit("some-root-event", "aaaaaaaaaaaaaaaaaaaaaa");
console.log('About $root.$emit')
}
Another component inside should catch this event but throws me an error:
this.$root.$on is not a function
The code of the second component looks like
mounted() {
this.$root.$on("some-root-event", (data) => {
console.log("About listener catch $root some-root-event"); console.log(data)
})
}
Can somebody help me please to understand where is the problem?