input file类型 上传同一个文件时 无法触发change方法

问题描述:

input为file类型时,点击上传同一个文件时,没有触发onChange(change)事件,上传不同的文件时,可以正常触发onChange事件

<input 
    type="file"
    accept=".csv"
    id="myUpload"
    @change="handleFileUpload"
/>

解决方案:

change事件处理完成之后,将valu设置为空

handleFileUpload () {
// 逻辑处理、方法请求

document.getElementById('myUpload').value = '' // 将value设置为空
}
posted @ 2024-05-29 10:33  yingzi__block  阅读(52)  评论(0编辑  收藏  举报