0👍
Normally, this.$root.$on
and this.$root.$emit
are not necessary and confusing.
If the <figure>
is in another comp, just do $emit('start-carousel', index)
directly, and in the parent:
<my-comp-width-figure @start-carousel="handleEvent" />
If the <figure>
is directly in the comp, then no need to do emits or whatsoever since both the handler and emitter are in the same context, just do:
<figure class="image">
<img :src="exe.img" :alt="exe.name" @click="handleEvent(index)">
</figure>
In both situations, handleEvent
would be the code that you have in your this.$root.$on
.
Hope this is clear.
Source:stackexchange.com