[Vuejs]-Vue iterating though object of arrays

2👍

The problem is inside your iteration index goes from 0 to 1: it’s kinda hard to explain but look at this fiddle: https://jsfiddle.net/tj5413om/2/ and you will see key 0 and 1 replace second loop from, but your data is the same:

[ { "2016": [ { "name": "stævne", "file": "pdf.pdf" }, { "name": "stævne", "file": "pdf.pdf" } ], "2017": [ { "name": "stævne", "file": "pdf.pdf" }, { "name": "stævne", "file": "pdf.pdf" } ] } ]

This does not have key 1: It’s only one array;

so replace your second loop from

<div v-for="(allYear, key) in results[index].year[index]" class="year">

to

 <div v-for="(allYear, key) in results[index].year[0]" class="year">
👤samayo

Leave a comment