微信小程序 this.setData is not a function
2017-10-16 16:15
726 查看
在一般的函数中:
this.setData是正确的。
但当在函数中有个请求(wx.request)时:
这样会报错误:this.setData is not a function.
解决方法就是 :在请求(wx.request)外面添加:var that=this;将success中的
改为:
来源:http://www.cnblogs.com/cocozj945/p/7068719.html
bindFaChange1: function (e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ index1: e.detail.value }) }
this.setData是正确的。
但当在函数中有个请求(wx.request)时:
formSubmit: function (e) { wx.request({ method: 'POST', header: header, url: url, dataType: 'json', success: function (res) { this.setData({ data1: true }) } }) }
这样会报错误:this.setData is not a function.
解决方法就是 :在请求(wx.request)外面添加:var that=this;将success中的
this.setData({ data1: true })
改为:
that.setData({ data1: true })
来源:http://www.cnblogs.com/cocozj945/p/7068719.html
相关文章推荐
- 微信小程序 this.setData is not a function
- 微信小程序 报错:this.setData is not a function
- 微信小程序提示this.setData is not a function解决方案之一
- 论微信小程序的坑:thirdScriptError TypeError: this.setData is not a function
- 微信小程序 this.setData is not a function
- 微信小程序报错:this.setData is not a function的解决办法
- 微信小程序 this.setData is not a function
- 微信小程序 this.setData is not a function;父元素获取
- 微信小程序中的坑:thirdScriptError this.setData is not a function;
- 微信小程序 this.setData is not a function
- 微信小程序 this.setData is not a function
- 微信小程序 this.setData is not a function
- 微信开发之this.setData is not a function;at pages/index/index onLoad function;at setTimeout callback func
- 小程序this.setData is not a function;api request success callback function解决方法
- 小程序给界面赋值报错:this.setData is not a function
- 小程序之坑一TypeError: this.setData is not a function
- 小程序that.setdata is not a function;
- [微信小程序]this.setData , that.setData , this.data.val三者之间的区别和作用
- 如何解决Uncaught TypeError: this.setState is not a function
- 微信小程序更换视图层数据this.setData