axios的post传值问题
axios({
url:"http://127.0.0.1:8000/index/saveuser",
method:"post",
data: this.form,
transformRequest: [function (data) {
// Do whatever you want to transform the data
let ret = ''
for (let it in data) {
// 如果要发送中文 编码
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
}
return ret
}],
headers: {'Content-Type':'application/x-www-form-urlencoded' }
}).then(res=>{
if(res.data.status){
ElMessage.success({
message: '恭喜你,' + res.data.message,
type: 'success',
})
this.form = {sex:'男'}
this.show = false
this.getUserByPage(this.currentPage)
this.getTotal()
}else{
ElMessage.error(res.data.message)
return false
}
})