Just started using Vue.js and I have a question:
I'm working with an array to create a table. When I double click on a table row, I want the program to execute a JavaScript function that will retrieve the selected item based on its index.
<div id="vm-table">
<table>
<tr v-for="(item, index) in items" @dblclick="getItem(index)">
<td>{{ index }}</td>
<td>{{ item.pk }}</td>
<td>{{ item.description }}</td>
</tr>
</table>
</div>
<script>
var vm = new Vue({
el: "#vm-table",
data: {
items: []
}
});
</script>
I believe that the array "items" already has a list of items. However, in the line within the "tr" element above, it seems that I cannot access the value of "index" and this value needs to be used within the inner "td" elements. How can I pass the index as a parameter if needed?
Thank you,