@whitesev/utils 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.amd.js +9 -1
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +9 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +9 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +9 -1
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +9 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Utils.d.ts +4 -2
- package/package.json +1 -1
- package/src/Utils.ts +12 -1
package/dist/index.umd.js
CHANGED
|
@@ -6065,11 +6065,19 @@
|
|
|
6065
6065
|
}
|
|
6066
6066
|
/**
|
|
6067
6067
|
* 将对象转换为FormData
|
|
6068
|
+
* @param data 待转换的对象
|
|
6069
|
+
* @param isEncode 是否对值为string进行编码转换(encodeURIComponent)
|
|
6068
6070
|
*/
|
|
6069
|
-
toFormData(data) {
|
|
6071
|
+
toFormData(data, isEncode = false) {
|
|
6070
6072
|
const formData = new FormData();
|
|
6071
6073
|
Object.keys(data).forEach((key) => {
|
|
6072
6074
|
let value = data[key];
|
|
6075
|
+
if (typeof value === "number") {
|
|
6076
|
+
value = value.toString();
|
|
6077
|
+
}
|
|
6078
|
+
if (isEncode && typeof value === "string") {
|
|
6079
|
+
value = encodeURIComponent(value);
|
|
6080
|
+
}
|
|
6073
6081
|
if (value instanceof File) {
|
|
6074
6082
|
formData.append(key, value, value.name);
|
|
6075
6083
|
}
|