uni.request提交的json数据,后台无法获取,用postmain工具可以获取到

- 发布:2018-10-18 12:01
- 更新:2021-09-01 17:28
- 阅读:11395

h***@163.com - Hickup
刚刚测试玩的时候,正好也遇到了这个问题,像上面说的,把请求头里面的Content-type改正确就对了
uni.request({
url:"http://localhost/login",
header:{
'Content-type':'application/x-www-form-urlencoded'
},
method:"POST",
data:{
username:"cun",
password:"123"
},
success:function(res){
console.log(res.data);
var jwtToken=res.data.jwtToken;
var msg=res.data.msg;
var stauts=res.data.status;
}
})

jtshushu - 擅长:PHP-Thinkphp Python MUI UniApp Vuejs Bootstrap Jq Logo设计 广告设计 网页设计 有项目上需要联系我微信号:jtshushu66
测试很久总是 解决了 最后是编码吗
header : {
'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
}
小鼎 (作者)
谢谢,已经解决了 Content-type换成application/x-www-form-urlencoded就可以了
2018-10-18 15:44