[Vuejs]-Vue listen and handle from Emits from elements inside slots

0👍

I didn’t get your problem but if you want a global emitter handler a common pattern is to create a singleton of a vue instance and import it when you need it.

src/bus/index.js

import Vue from 'vue'

const bus = new Vue()

export default bus

src/components/Whatever.vue

import bus from 'src/bus'

// And then in your functions
bus.$on(...)
bus.$emit(...)
bus.$off(...)

If you’re looking for a more structured event system, you should take a look at the store pattern with vuex.

Leave a comment