I have two Vue components:
Vue.component(\'A\', {});
Vue.component(\'B\', {});
How can I access component A from component B? How does the
Communication between the components can also be established by creating a single global event hub in your Vue application. Something like this:-
var bus = new Vue();
Now you can create custom events and listen to them from any component.
// A.vue
// ...
doThis() {
// do the job
bus.$emit('done-this');
}
// B.vue
// ...
method:{
foo: function()
}
created() {
bus.$on('done-this', foo);
}
More about this can be found from official documentation..