2π
β
I donβt know if itβs possible to access the fruit $index
inside the inner v-repeat
, but you could try something like this:
<table>
<tr>
<th>Fruits</th>
<th>Summer</th>
<th>Winter</th>
</tr>
<tr v-repeat="fruit: fruits">
<td v-text="fruit"></td>
<td v-repeat="season: seasons" v-text="isAvailable(fruit, season)"></td>
</tr>
</table>
and
data: {
fruits: [
'apple', 'orange', 'banana'
],
seasons: [
'summer', 'winter'
],
available: {
summer: ['yes', 'no', 'yes'],
winter: ['yes', 'no', 'no']
}
},
methods: {
isAvailable: function (fruit, season) {
var fruitIndex = this.fruits.indexOf(fruit)
return this.available[season][fruitIndex]
}
}
π€Pantelis Peslis
Source:stackexchange.com