We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
let resetFileDom = dom => { if (({}).toString.call(dom) !== '[object HTMLInputElement]') { throw new Error('必须传入DOM节点') return } dom.value = '' dom.type = 'text' dom.type = 'file' }
The text was updated successfully, but these errors were encountered:
直接 dom.value='' 不行吗?
dom.value=''
Sorry, something went wrong.
@chbro 近期我也有操作上传文件一直想清空😊。试了你的方案成功清空。👍
@xmcp 可以直接设置为空('' | null) (chrome 69 firefox 62 edge17) https://codepen.io/Yangfan2016coding/pen/aaXoez?editors=1111
直接 dom.value='' 有兼容性问题
考虑兼容性,也可以这样
<form id="uploadField"> <input type="file" /> </form>
window.uploadField.reset()
但是要注意 form 不能嵌套 form,最好 Portal 到其他地方
No branches or pull requests
The text was updated successfully, but these errors were encountered: