Answer the question
In order to leave comments, you need to log in
Why is v-for not working in vue?
HTML
<div id="app">
<records></records>
</div>
Vue.component('records', {
template: ' <div>{{orders}}</div> <div><div v-for="order in orders"> {{order.id}}</div></div>',
data: function() {
return{
orders: [{id: 1}, {id: 2}, {id: 3}]
}
},
created: function () {
this.getOrders();
},
methods: {
getOrders: function () {
var vm = this;
axiosInst.get('/records')
.then(function (response) {
//vm.$set('ordersList', response.data);
vm.orders = response.data.slice();
console.log(vm.orders);
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
},
}
})
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
})
Answer the question
In order to leave comments, you need to log in
Perhaps because your records component template has more than one root element.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question