mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user