5

vue3中清空input type="file"上传文件

 2 years ago
source link: https://segmentfault.com/a/1190000040845030
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

1、添加ref

<input type="file" ref="uploadFile" />

2、获取input file

...
setup () {
let uploadFile = ref('uploadFile')
return {
  uploadFile
}

3、执行清空操作

setup () {
...
  const clearInput = () => {
    uploadFile.value.value = ''
  }
...
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK