I have an array, with sizes of shoes and quantity each of them in shop, structure like this:
array = {
36=>1,
37=>0,
38=>5,
39=>2
}
In my table key in this table ( here 36, 37 ... ) are TH, and value is TD. I can't do this in one loop. I tried like this:
<table class="table">
<tr>
<th v-for="(quantity, key) in productSizes" :key='key'>{{key}}</th>
</tr>
<tr>
<td>Here should be quantity for each size<td>
</tr>
</table>
Is there a possibility to do this at once?
Here is structure how it should look like (there is an input, because someone can change quantity).
I cannot conceive of a way you could do this in one loop, nor do I think it's worth the effort. Just loop a second time over the same data structure and you will always get matching columns.
Assuming there were even 100 shoe sizes the performance impact would be negligible.
Edit
Well, I can think of one way you could render it in one loop. Using a render function.
This render function builds the headers and cells in the same loop and then renders the table around them. But I think you would agree this is needlessly complex.