onLoad: function () {
wx.request({
url: '接口地址', //仅为示例,并非真实的接口地址
data: {
id: '1',
position: '2',
class_id: '3'
},
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded' // 默认值
},
success(res) {
console.log(res.data)
}
})
}
后台可以以key/value值获取到传参
header: {
'content-type': 'application/x-www-form-urlencoded'
},
这样写获取不到
header: {
'content-type': 'application/json' // 默认值
},