今天 大年初六 , AND axios 使用时遇到了点小问题,
if (valid) {
// debugger
console.log(JSON.stringify(this.formValidate));
var params = new URLSearchParams();
params.append('name', JSON.stringify(this.formValidate));
// params.append('id', '2');
this.$Message.success('Success!');
this.$Loading.start();
this.$ajax.post('http://localhost:3000/dataLists', params, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
.then(function (response) {
console.log(response);
// this.$Loading.finish();
})
.catch(function (error) {
console.log(error);
// this.$Loading.error();
});
} else {
this.$Message.error('失败!----->请认真点');
}
需要加上:
var params = new URLSearchParams();
params.append('name', JSON.stringify(this.formValidate));
最后params 放在你传的参数里就可以了