2018-12-21 08:37:00 卢浮宫 版权声明:本文为站长原创文章,转载请写明出处
今天在做微信小程序时由于get请求无法达成预期,所以需要使用post请求,查了资料,记录如下。
①需要在wx.request中表明使用方法 method:POST
②需定义请求头为 "Content-Type": "application/x-www-form-urlencoded"
wx.request({
url: "your url",
method: "POST",
data: {
params: JSON.stringify(params)
},
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
success(res) {
console.log(res);
if (!res.data.success) {
wx.showToast({
title: "操作失败!",
})
}
}
})