1. 编写目的
解决如题所示问题:微信小程序提交post请求后台拿不到数据。
2. 解决方法
只需要在wx.request中添加如下属性即可:
header: {"Content-Type": "application/x-www-form-urlencoded" },
总的代码如下:
wx.request({method: "POST",// 一定要添加下面这行才可以header: {"Content-Type": "application/x-www-form-urlencoded" },url: 'http://127.0.0.1/diary/add',data: {content: ,mood: mood,weather: weather,userid: user,session_key: session }});
3. 总结
这是个坑!
Smileyan 3月2日