为什么在wx.showModal中使用不了that?(that=this)

小程序 文章 2021-04-09 09:42 467 0 全屏看文

为什么在wx.showModal中使用不了that?(that=this)Why can't that be used in wx.showModal? (that=this)

为什么在wx.showModal中使用不了that?(that=this)

为啥我在wx.showModal中访问不到定义在外边的that呀?打印that显示undefined,代码中也可以看到that是浅色的,说明只定义了没有使用吧?帮帮小白吧~ 谢谢啦!

Why am I here wx.showModal Can't access that defined outside? Print that to show undefined. You can see that is light in the code. Does that mean that it is only defined but not used? Help Xiaobai, thank you!

回答:

peng:

signUpBut 调用的作用域有问题,看下这里面的是不是在回调函数中使用this.signUpBut,是的话外层声明 var that=this ;调用使用that.signUpBut

this:

var 改为let看看

HB_:

var that = this 放在if里面的首行定义

-EOF-