1、POST请求获取到请求参数为null
官方文档的例子是:
wx.request({
url: 'test.php', //仅为示例,并非真实的接口地址
data: {
x: '' ,
y: ''
},
header: {
'content-type': 'application/json' // 默认值
},
success: function(res) {
console.log(res.data)
}
})
如果请求是POST请求如果没有
header: { "Content-Type": "application/x-www-form-urlencoded" },那么后台获取不到请求参数。
2、button样式border:none设置无效
去除button边框样式需要在::after伪类选择器中设置,如下:
.handBt{
background: #fff;
font-size: 14px;
height: auto;
padding: 0px;
color: #0AB944;
}
.handBt::after{
border:none;
}
3、request请求的success回调中获取data数据,报undefined错误
微信小程序中,在wx.request({});方法调用成功或者失败之后,有时候会需要获取页面初始化数据data的情况,如果使用this.data来获取,会报undefiend。原因是this表示当前对象,在回调函数中,this对象已经改变,所以获取不到data中的数据,解决方式是在请求之前,调用var that=this;
在回调函数中使用that.data.**就能获取到数据了。