wx.request({
url: 'test.php', //仅为示例,并非真实的接口地址
data: {
x: '' ,
y: ''
},
header: {
'content-type': 'application/json' // 默认值
},
success: function(res) {
console.log(res.data)
}
})
刚开始前端同事把header注释了传值,结果我后端收不到任何参数打印post是空,在网上找的是设置
header: {
'content-type': 'application/x-www-form-urlencoded'
},就收到了
本文介绍了一个前端使用wx.request向后端发送数据时遇到的问题。起初由于header配置缺失导致后端无法接收到参数,通过调整header中'content-type'的设置为'application/x-www-form-urlencoded'解决了该问题。
1万+

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



