In my JS file, I have two components. The file starts with this line: const EventBus = new Vue();
I am trying to pass two strings, 'username' and 'password', from the first component to the second component, but it's not working. Can you help me identify where I am going wrong?
First Component:
Vue.component('log-reg-modal', {
data: () => ({
username: "",
password: "",
}),
watch: {
username: function(){
EventBus.$emit('changed_username', this.username);
},
password: function(){
EventBus.$emit('changed_password', this.password);
},
}
});
Second Component:
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
username: "",
password: "",
}),
methods: {
register : function (event) {
EventBus.$on('changed_username', this.username);
EventBus.$on('changed_password', this.password);
}
}
});