I misunderstood the documentation of passing child component to other child component.
I have two components
index.html
<main-categories-products source="{{ url('api/products') }}">
</main-categories-products>
<sidebar-options> </sidebar-options>
My app.js
var app = new Vue({
el: '#app',
components: {
MainCategoriesProducts,
SidebarOptions
}
})
MainCategoriesProducts.vue
import Vue from 'vue'
var bus = new Vue()
export default{
props: ['source'],
created(){
this.fetchedProduct()
},
methods: {
fetchedProduct: function(){
var data = [1,2, 3];
bus.$emit('did-something', data);
}
}
}
My SidebarOptions.vue
import Vue from 'vue'
var bus = new Vue()
export default{
data(){
return {
someData: {}
}
},
created(){
bus.$on('did-something', data => this.someData = data);
console.log(this.someData)
}
}
No errors but I can't get the data from MainCategoriesProducts to SidebarOptions. How can I get those data = [1, 2, 3]? TY