I need a nested v-for loop in Vuejs but have doubt about how to do it, how to organize my Data and the v-for loop.
Here is the Data. I would like to be able to iterate through modifiers, without the need to call precisely modifiers1, modifiers2.
The idea is that the first v-for loop with iterate through the modifiers object, and a nested v-for loop will iterate through the different blocks inside. Like this, I have an automatic nested v-for loop.
modifiers1: {
block1: {
class: 'doc_button--green',
description: 'Primary Button'
},
block2: {
class: 'doc_button--orange',
description: 'Secondary Button'
},
block3: {
class: 'doc_button--red',
description: 'Tertiary Button'
}
},
modifiers2: {
block1: {
class: 'doc_button--small',
description: 'Small Button'
},
block2: {
class: 'doc_button--big',
description: 'Big Button'
}
}
A simple example of loop I think about is:
<div v-for="(modifier) in modifiers" :key="modifier">
<ul v-for="(block) in blocks" :key="block">
<li></li>
</ul>
</div>
Is it possible, and if yes how? Do I need to organize my Data into a nested array? Thanks
modifiers
andblocks
blocks
has no relation tomodifiers