[Vuejs]-Vue js issues with passing event and index as parameter

2👍

As a workaround, you can pass index as a data attribute instead,

<input hidden id="imgload" type="file" @change="previewImage($event)" accept="image/*" :data-index="index">

and in your method, get the index using event.target.dataset.index

previewImage: function(event) {
    const index = event.target.dataset.index;
    //...

           console.log(index);
    //...
   }

Leave a comment