分析问题在哪里
wx.request({
url: 'test.php', //仅为示例,并非真实的接口地址
data: {
x: '',
y: ''
},
header: {
'content-type': 'application/json' // 默认值
},
success (res) {
console.log(res.data)
}
})
这个是官方文档给出的例子,不能直接拿来用!
注意这几个问题:
服务器端在设计时使用的是什么方式接收数据,GET?还是POST?
上述代码的method未填写,说明走的是默认方式
注意method的默认是GET
再考虑:
POST传递数据有四种方式,
text/xml
application/json
multipart/form-data
application/x-www-form-urlencoded
这个也需要填写清楚。
善用文档和Google