Skip to content

Commit 7fd5643

Browse files
author
puhui999
committed
fix: 修复多文件上传一个一个选择上传第二个文件上传失效的问题
1 parent 5e265a9 commit 7fd5643

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/UploadFile/src/UploadFile.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ const beforeUpload: UploadProps['beforeUpload'] = (file: UploadRawFile) => {
100100
// 文件上传成功
101101
const handleFileSuccess: UploadProps['onSuccess'] = (res: any): void => {
102102
message.success('上传成功')
103-
fileList.value.shift()
103+
// 删除自身
104+
const index = fileList.value.findIndex((item) => item.response?.data === res.data)
105+
fileList.value.splice(index, 1)
104106
uploadList.value.push({ name: res.data, url: res.data })
105107
if (uploadList.value.length == uploadNumber.value) {
106108
fileList.value.push(...uploadList.value)
@@ -144,6 +146,7 @@ watch(
144146
fileList.value.push(
145147
...val.split(',').map((url) => ({ name: url.substring(url.lastIndexOf('/') + 1), url }))
146148
)
149+
return
147150
}
148151
// 情况2:数组
149152
fileList.value.push(

0 commit comments

Comments
 (0)