// Send a POST request
axios({
method: 'post',
url: this.url + 'vdata/vdata_cate/createVdataCateProcess',
data: {
param:JSON.stringify(this.formValidate),//转为json字符串
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
}).then((response) => {
//刷新taken 第10步
this.getNewToken();
if (response.data.r == "success") {
swal({
type: "success",
title: "成功!",
text: "添加成功",
confirmButtonText: "确认",
allowOutsideClick: true,
timer: 1300,
}, function() {
//取消窗口
});
} else {
console.log(response.data);
swal({
type: "error",
title: response.data,
});
}
});
param的数据始终post不过去
headers 中的 ContentType 和 Payload 冲突
经过
JSON.stringify
转换后是一个 JSON 字符串,但是application/x-www-form-urlencoded
要求是使用key=value
的形式对参数进行包装,多个参数使用&
拼接。解决办法。
qs.stringify
处理对象。JSON.stringify
将Content-Type
修改为application/json
。