Browse Source

http处理提交数据中值为undefined的改成空字符串

ming 2 years ago
parent
commit
0326cc3a8c
2 changed files with 10 additions and 1 deletions
  1. 1 1
      package.json
  2. 9 0
      utils/http.js

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "fs-uni",
-  "version": "2.5.0",
+  "version": "2.5.1",
   "description": "",
   "main": "main.js",
   "dependencies": {

+ 9 - 0
utils/http.js

@@ -70,6 +70,15 @@ methods.forEach(method => {
 			}
 		}
 		
+		// 提交数据中值为undefined的改成空字符串
+		if (typeof data === 'object') {
+			for (let key in data) {
+				if (data[key] === 'undefined') {
+					data[key] = ''
+				}
+			}
+		}
+		
 		return request(method, url, data, opt)
 	}
 })