I am looking for creating a menu by iterating on a nested object in the data object of Vuejs.
Here is the loop I have thought of:
<ul v-for="category in categories" :key="category"> {{ category }}
<li v-for="subCategory in category" :key="subCategory">
<router-link to="/"> {{ subCategory }} </router-link>
</li>
</ul>
It would a simple menu with a one level of nested sub-menus.
categories: [{
Atoms: ['Buttons', 'Icons'],
Molecules: [],
Organisms: [],
Templates: [],
Utilities: ['Grid']
}]
It is a component, so with the data: function(){}.
I know it is an easy problem but I don't manage to get a clean list with the menus (Atoms, Molecules...) as the ul, and the sub-menus (string in each array) as the li. Right now, I get the all array on the screen, with the [] and {}.
And I don't why Vuejs, when I look in Chrome console, adds some '0' objects between each layer of data.
Thanks for your help. I tried to make a JSfiddle but it didn't work at all.