查看app.log,$_POST['']空空如也。
https://ask.dcloud.net.cn/question/77082
加上 "Content-Type": "application/x-www-form-urlencoded"试试
复制代码uni.request({
url: 'https://www.example.com/request', //仅为示例,并非真实接口地址。
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: {
name: 'name',
age: 18
},
method: 'POST',
success: function(res) {
console.log(res.data);
}
莫名其妙。我用的application/json。
但是改了就对了。

本文探讨了在查看app.log时发现$_POST['']为空的问题,并分享了解决方案:通过在请求头中添加Content-Type:application/x-www-form-urlencoded来确保数据正确传递。
959

被折叠的 条评论
为什么被折叠?



