cancel执行之后,files第二次为空。
Closed this issue · 2 comments
hankaibo commented
handleFilesAdded(files) {
if (files.length > 5) {
this.$message.error('最多上传5个文件,请重新上传。')
this.handleClosePanel()
} else {
this.dropBoxShow = false
this.panelShow = true
this.collapse = false
files.forEach((item) => {
if (item.size > SIZE_1G) {
this.$message.error(`${item.name}超出最大1G限制,将不被上传。`)
item.cancel()
} else {
this.computeMD5(item)
}
})
}
}
代码片段如上,当第一次选择一个大于1G的文件上传,它弹出提示信息;当再选择时这个文件上佳时,files变为空了,页面就没有任何反应了。
请问是不是item.cancel()使用错了呢?
hankaibo commented
如果不item.cancel()的话,就会将文件添加到上传列表中,那我应该不将这个item加入呢?