0👍
Try to change your code in this:
created() {
var instance = this;
this.$bus.$on('PostInfo', function (res) {
console.log(res);
instance.item = res;
instance.itemTitle = res.title;
});
}
The problem should be that inside your function the this
is not the instance of your component.
0👍
Ok i finally found the solution.
I forget the bus element to pass data and i start to use vuex store like this:
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
data: null
}
})
And in the file i want to send data i do that:
goRetro: function (item) {
this.$store.replaceState(item)
}
And finally to capture data in the target component i do that:
created () {
var dataValue = this.$store.state
this.itemTitle = dataValue.title
}
I hope it can help people
- [Vuejs]-Add an undefined method promise to an array to be resolved later in Promise.all()
- [Vuejs]-How to make a <tr> element in vuejs that contains <slot> with html
Source:stackexchange.com