微信开发之this.setData is not a function;at pages/index/index onLoad function;at setTimeout callback func
2018-02-01 18:00
2066 查看
执行微信代码报错:
WAService.js:3 thirdScriptError
this.setData is not a function;at pages/index/index onLoad function;at setTimeout callback function
TypeError: this.setData is not a function
at Function.<anonymous> (http://127.0.0.1:9973/appservice/pages/index/index.js:53:12)
at http://127.0.0.1:9973/appservice/__dev__/WAService.js:3:13773 at http://127.0.0.1:9973/appservice/__dev__/WAService.js:8:5308 代码如图:
把this改成getApp()错误依旧:
解决方法:在函数中加入var that = this;修改后如图
总结:
1、如果函数作为对象的方法调用,this指向的是这个上级对象,即调用方法的对象。
2、如果是构造函数中的this,则this指向新创建的对象本身。
WAService.js:3 thirdScriptError
this.setData is not a function;at pages/index/index onLoad function;at setTimeout callback function
TypeError: this.setData is not a function
at Function.<anonymous> (http://127.0.0.1:9973/appservice/pages/index/index.js:53:12)
at http://127.0.0.1:9973/appservice/__dev__/WAService.js:3:13773 at http://127.0.0.1:9973/appservice/__dev__/WAService.js:8:5308 代码如图:
把this改成getApp()错误依旧:
解决方法:在函数中加入var that = this;修改后如图
总结:
1、如果函数作为对象的方法调用,this指向的是这个上级对象,即调用方法的对象。
2、如果是构造函数中的this,则this指向新创建的对象本身。
相关文章推荐
- 微信小程序 报错: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;api request success callback 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解决方案之一
- 微信小程序 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
- 小程序之坑一TypeError: this.setData is not a function
- 小程序that.setdata is not a function;
- 关于Uncaught TypeError: type is not a function at HTMLAnchorElement.onclick (indexjsp:71)的解决
- 解决ajaxpro 9.2.17.1 中 this.onTimeout is not a function 的错误
- this.setState is not a function