Reputation: 5255
In vuejs you can do list rendering in the template like
<td v-for="item in items"></td>......
But can you iterate over that same data array property like....
for(var i = 0; i < this.items.length; i++)
this.$data.items[i]
Upvotes: 1
Views: 5938
Reputation: 1655
this post is quite old, but this can be useful to anyone who wants to iterate into an array of object.
Instead of:
for(var i =0; i < this.items.length; i++) {
console.log(this.items[i]);
}
You can do this a little bit more concisely and more readable (in my opinion):
this.items.forEach((item) => {
console.log(item);
})
Upvotes: 2
Reputation: 6574
yes
Just don't worry about the this.$data.items
, instead this.items
, although it would also work ...
Upvotes: 2