Answer the question
In order to leave comments, you need to log in
How to iterate in VUE.JS using v-for objects that I receive from the server?
First I get my objects
created() {
this.$http.get('/api/main-page/transports/get-transports').then(response => {
this.personalTransportTabs = response.body.personalTransportTabs;
this.dataLoaded = true;
}).catch(error => {
console.log(error);
});
}
data() {
return {
personalTabs: this.personalTransportTabs
};
},
<el-tab-pane v-for="personalTab in personalTabs" :label="personalTab.name" >{{ personalTab.name }}</el-tab-pane>
Answer the question
In order to leave comments, you need to log in
this.$set
created() {
this.$http.get('/api/main-page/transports/get-transports').then(response => {//Эта функция будет выполнена после инициализации
this.$set(this,'personalTabs', response.body.personalTransportTabs);
this.dataLoaded = true;
}).catch(error => {
console.log(error);
});
},
data() {
return {
personalTabs: []
};
},
The fields in data are reactive, just do an assignment when you get the data:
This will trigger an automatic re-render.
This will not work for you : Because data is initialized once when an instance is created. personalTabs: this.personalTransportTabs
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question