在执行异步发送数据是,回传的success里面对paga里面data数据进行赋值,原this.setData({变量:值})是无效的,因为this对象已经不是page了,正确的应该是:
//1.验证手机号码是否存在
var that = this; //这里*******************
wx.request({
//发送
url: 'https://www.app.com/checkphone', //
data: {
phoneNum: this.data.phoneNum,
},
header: {
'content-type': 'application/json' // 默认值
},
success (res) {
if(res.data.state == '0'){
that.setData({pisexist:true}); //这里************
return false;
}
}
});