Answer the question
In order to leave comments, you need to log in
Should vue track data changes in the parent?
There is an application on the view, where there is a main object and components. All this works through vue-cli, that is, broken down into components.
I use the main view object as a repository of information that is convenient to use from all components.
It looks something like this:
new Vue({
...
data: {
userInfo: {},
messages: {},
...
}
});
this.$root.userInfo.name = 'Vasya';
this$root.messages.push({text: 'New message'});
<li v-for="message in $root.messages">{{ message.text }}<li>
#mycomponent
data: function() {
return {
messages: []
}
},
created: function() {
this.messages = this.$root.messages
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question