在一般的函數(shù)中:
bindFaChange1: function (e) {
console.log('picker發(fā)送選擇改變,攜帶值為', e.detail.value)
this.setData({
index1: e.detail.value
})
}
this.setData是正確的。
但當(dāng)在函數(shù)中有個(gè)請(qǐng)求(wx.request)時(shí):
formSubmit: function (e) {
wx.request({
method: 'POST',
header: header,
url: url,
dataType: 'json',
success: function (res) {
this.setData({
data1: true
})
}
})
}
這樣會(huì)報(bào)錯(cuò)誤:this.setData is not a function.
解決方法就是 :在請(qǐng)求(wx.request)外面添加:var that=this;將success中的
this.setData({
data1: true
})
改為:
that.setData({
data1: true
})
Latest Signing
App Develop
Common Problems
Website Construction
Weixin Develop
Mobile Website
Website Optimization
Website Optimization
Website Design
Host/Domain