Hi I am new to vue and I am wondering how to data-bind from one component to another.
export default {
name: 'dashboard-sidebar',
methods: {
monthChange: function (event) {
var selectedMonth = $("#sel1").val();
this.$root.$emit('changed', selectedMonth);
},
dashboardReportsChange(value){
var selectedDashboard = value;
this.$root.$emit('click', selectedDashboard);
}
}
}
I want to get the value of the variables I declare and data-bind it into another component in my app.
export default {
components:{
dashboardsidebar
},
mounted() {
this.$root.$on('changed', (selectedMonth) => {
console.log(selectedMonth);
})
this.$root.$on('click', (selectedDashboard) => {
console.log(selectedDashboard)
})
}
}
This is my other component.