I am using v-for
to loop through an array of objects. The list has a file input inside. On the change event of the file input, I am calling a method with a parameter. The problem is that the parameter value is not getting changed the same value is getting passed in all the file inputs.
<li v-for="(item, index) in this.ailment_details_form.items" :key="item.id">
<input type="file" v-on:change="handleFileUpload(item.id)" />
<label>@{{ item.id }}</label>
</li>
This is the method.
handleFileUpload(i) {
console.log(i);
}
Below is the data.
ailment_details_form: {
details: '',
items: [
{ id: 1, text: "Item 1" },
{ id: 2, text: "Item 2" },
{ id: 3, text: "Item 3" }],
files: [],
urls: []
}
Here item.id
in handleFileUpload()
method is always showing as 1. Where as inside label
it is showing correctly. Please help.