[Vuejs]-Pass cell indices to event handler

0๐Ÿ‘

โœ…

@Solution

<table id="app">
 <tr v-for="(i, row) in rows">
  <td v-for="(j, cell) in row", @click="getCell(i, j)">
   {{cell}}
  </td>
 </tr>
</table>

new Vue({
  el: '#app',
  data: {
    rows: [
      [11, 12, 13],
      [21, 22, 23]      
    ]
  },
  methods: {
    getCell: (i, j) => console.log(i, j)
  }
})

Leave a comment