I can't find much information on the web with explanation on how to use multiple vuejs instances and make them work together.
Please, can someone show me his code style on how to do that?
I have a main /resources/assets/js/app.js:
Vue.component('google-maps', require('./components/Gmaps.vue'));
export const App = window.App = new Vue({
el: '#app',
mounted(){
// Listen for an event
socket.on('alarm-channel:App\\Events\\AlarmCreated', ({data}) => {
return this.alarmCreated(data.alarm);
});
},
data: {
users: [],
alarms: [] // #01 - should be in Alarms.js
},
methods: {
/* Newly registered alarm */
alarmCreated(alarm){
this.alarms.push(alarm); // #01 - should be in Alarms.js
}
}
});
How can I call a same new Vue() inside /resources/assets/js/alarms.js to make it work together ?:
alarm.js, and load that component into theAppcomponent (import Alarm from './alarm.js'{el: '#app', components: 'Alarm', ... }). You could also useVuexto manage your statealarms.jsfile? The same way asapp.jsdid not workvuexand check this fiddle: jsfiddle.net/n9jmu5v7/1269 (fromvuexdocumentation here: vuex.vuejs.org/en/getting-started.html)