还有什么别的解决方法吗
this.setData报错,网上搜索解决办法把this改成that还是报错是什么问题呢?this.setData reports an error, what is the problem of changing this to that or reporting an error when searching for solutions on the Internet?
this.setData报错,网上搜索解决办法把this改成that还是报错是什么问题呢?还有什么别的解决方法吗
Is there any other solution
回答:
你明白来this指的啥含义就明白为啥改成that,然后把that生命放在什么地方了
let that = this; 写在最外层
你wx.login外层的this指向已经不对了,所以你不管写啥箭头函数,写啥that都不行
我猜你是在app.js 中使用 了setData
你知道为什么要把this改成that吗?
作用域的问题
写在 page({
onload:(){
let that = this; //写在外层,page里面的方法下
}
})
若认为该回答有用,给回答者点个[ 有用 ],让答案帮助更多的人