Skip to content

Instantly share code, notes, and snippets.

@adi518
Last active September 17, 2017 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adi518/1a13b6708085eacf4dbe2f9655ee5b14 to your computer and use it in GitHub Desktop.
Save adi518/1a13b6708085eacf4dbe2f9655ee5b14 to your computer and use it in GitHub Desktop.
Vue Global Event-Bus
// ./components/EventBus.vue
import Vue from 'vue'
export const EventBus = new Vue()
// ./plugins/EventBus.js
export default {
install(Vue) {
const { EventBus } = require('../components/EventBus')
Vue.prototype.$bus = EventBus
}
}
// ./main.js
import EventBus from './plugins/EventBus'
Vue.use(EventBus)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment