Last active
September 17, 2017 20:51
-
-
Save adi518/1a13b6708085eacf4dbe2f9655ee5b14 to your computer and use it in GitHub Desktop.
Vue Global Event-Bus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ./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