2👍
✅
I reproduced the sample that you’ve included into it’s vue counterpart.
new Vue({
el: "#app",
data: {
days: [1,2,3,4,5],
itemList: [
{
name: 'Apple'
},
{
name: 'Banana'
},
{
name: 'Carrot'
}
]
},
methods: {
alert(item_index, day_index) {
let item = this.itemList[item_index];
let day = this.days[day_index];
alert(item.name + ', Day ' + day);
}
}
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<div id="app">
<table border="1">
<thead>
<tr>
<th>Day/Time</th>
<th v-for="day in days" width="50">Day {{ day }}</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, item_index) in itemList" :key="item.name">
<td>{{ item.name }}</td>
<td v-for="(day, day_index) in days" @click="alert(item_index, day_index)">Click</td>
</tr>
</tbody>
</table>
</div>
See this JS Fiddle:
https://jsfiddle.net/eywraw8t/180692/
Source:stackexchange.com