uni-app中很多东西不能试用?
1,uni-app中不能用色上司浏览器缓存。不能试用formdata。
在uni-app中如何试用formData呢?
verifyPasswordLogin: (params) => {
const ApiToken = uni.getStorageSync("apiToken");
return new Promise((resolve, reject) => {
uni.request({
url: `${baseUus}/login`,
method: "POST",
header: {
"content-type": "multipart/form-data; boundary=XXX",
Authorization: `Bearer ${ApiToken}`,
},
data: params,
success: (res) => {
if (res.data.code == '0') {
resolve(res.data.data);
}
},
});
});
},
外加这个转化
export function paramsToFormData (obj = {}) {
let result = ''
for (let name of Object.keys(obj)) {
let value = obj[name];
result +=
'\r\n--XXX' +
'\r\nContent-Disposition: form-data; name=\"'+ name +'\"'+
'\r\n' +
'\r\n' + value
}
return result + '\r\n--XXX--'
}