I have two Vue components:
Vue.component(\'A\', {});
Vue.component(\'B\', {});
How can I access component A from component B? How does the
In addition to pesla' answer take a look at the guide's State Management section under Building large scale apps: http://vuejs.org/guide/application.html#State_Management . I've created a jsfiddle based on that here: https://jsfiddle.net/WarwickGrigg/xmpLg92c/.
This technique works for components too: parent-child, sibling-sibling component relationships etc.
var hub = {
state: {
message: 'Hello!'
}
}
var vmA = new Vue({
el: '#appA',
data: {
pState: {
dA: "hello A"
},
hubState: hub.state
}
})
var vmB = new Vue({
el: '#appB',
data: {
pState: {
dB: "hello B"
},
hubState: hub.state
}
})