Compare commits

..

1 Commits

Author SHA1 Message Date
yutent 763792d7f1 fixed undefined 2024-10-28 17:16:12 +08:00
2 changed files with 14 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@bytedo/fetch", "name": "@bytedo/fetch",
"version": "2.1.7", "version": "2.1.8",
"description": "全新的ajax封装。分2个版本, 一个基于XMLHttpRequest, 一个基于window.fetch", "description": "全新的ajax封装。分2个版本, 一个基于XMLHttpRequest, 一个基于window.fetch",
"main": "dist/next.js", "main": "dist/next.js",
"files": [ "files": [

View File

@ -84,13 +84,17 @@ export const Format = {
mkFormData(data) { mkFormData(data) {
let form = new FormData() let form = new FormData()
for (let i in data) { for (let i in data) {
let el = data[i] let val = data[i]
if (Array.isArray(el)) { if (val === void 0) {
el.forEach(function (it) { val = ''
}
if (Array.isArray(val)) {
val.forEach(function (it) {
form.append(i + '[]', it) form.append(i + '[]', it)
}) })
} else { } else {
form.append(i, data[i]) form.append(i, val)
} }
} }
return form return form
@ -105,6 +109,11 @@ export const Format = {
if (/native code/.test(v)) { if (/native code/.test(v)) {
return return
} }
if (v === void 0) {
v = ''
}
let _type = getType(v) let _type = getType(v)
v = typeof v === 'function' ? v() : v v = typeof v === 'function' ? v() : v