fix(components): [upload] fix empty array error (#13490)

* fix(components): [upload] fix empty array error

在 components/upload/src/ajax.ts 73 行中,如果data 中key对应的value 是空数组的情况下`if (Array.isArray(value)) formData.append(key, ...value)`报错

* fix: reuse isArray

---------

Co-authored-by: btea <2356281422@qq.com>
This commit is contained in:
arvin
2023-08-13 10:23:06 +08:00
committed by GitHub
parent b9a8879e06
commit 5c1306127f

View File

@@ -1,5 +1,5 @@
import { isNil } from 'lodash-unified'
import { throwError } from '@element-plus/utils'
import { isArray, throwError } from '@element-plus/utils'
import type {
UploadProgressEvent,
UploadRequestHandler,
@@ -70,7 +70,7 @@ export const ajaxUpload: UploadRequestHandler = (option) => {
const formData = new FormData()
if (option.data) {
for (const [key, value] of Object.entries(option.data)) {
if (Array.isArray(value)) formData.append(key, ...value)
if (isArray(value) && value.length) formData.append(key, ...value)
else formData.append(key, value)
}
}