wx小程序里面this是什么意思 求大神们带飞
发布于 6 年前 作者 chaozhao 13843 次浏览 来自 问答

let thispage = this;

timer = setInterval(function () {

if (abc >= 3) { abc = 0; }

thispage.setData({ fang: thispage.data.srca[abc] })

比如这个我打的例子

知道大概意思但是

thispage.setData

thispage.data.srca

let thispage 这三个不知道什么意思  

5 回复

恩恩谢大神带飞

刚刚学习

thispage=this

thispage.setData是不是就相当于

this.setData??/

en 了解了谢谢

是的,而且考虑到this在多层嵌套、回调的时候,

一般都喜欢

let that = this , 方便在多层、回调中使用

或则你用 => 绑定 this

你在 onload  console.log(this)

就好比 react

this.setData ===> this.setState

this.data  ===> this.state

剩下的就是生命周期不一样而已

就是一个是当前页面的对象

回到顶部