5👍
the problem is that your input[type=file]
is into a v-for
. So there is probably more than just one $refs['file1']
.
You should work with the targeted input element for your event:
<div id="app">
<input type="file" name="myFile" @change="fileChanged">
</div>
new Vue({
el: '#app',
methods: {
fileChanged (e) {
console.log(e.target.files)
}
}
})
3👍
I changed the code to this one and works perfectly.
filesChange(fieldName, fileList) {
console.log (fileList)
if (!fileList.length) return;
this.files[0]=fileList[0];
}
Source:stackexchange.com