请问一下微信小程序延时函数如何调用自己定义的函数?

小程序 文章 2020-08-19 23:01 702 0 全屏看文

AI助手支持GPT4.0

请问一下微信小程序延时函数如何调用自己定义的函数?How does the WeChat applet delay function call the function defined by yourself?

请问一下微信小程序延时函数如何调用自己定义的函数?

在小程序开发中,我原本的想法是:Modelnoon是一个事件点击函数,当他执行时,第一步先执行TurnOffled这个函数,然后过秒再执行TurnOnCurtain这个函数

现在的话这么写 调试器报错 说我TurnOnCurtain没定义 实际上我定义了。

另外的话,我没用延时函数写了一种:

它正常运行 第一步关灯 然后第二步关窗帘 可是它运行完第一步后又把灯点亮了

In the development of small programs, my original idea is: modelnoon is an event click function. When it is executed, the first step is to execute the function of turnoff, and then execute the function of turnoncurtain in seconds. Now, the debugger reports that I have no definition of turnoncurtain, but I have defined it. In addition, I did not use the delay function to write one: it works normally, the first step is to turn off the light, then the second step is to close the curtain, but it turns on the light after the first step

回答:

stop eating:
 setTimeout(this.TurnOnCurtain, 300)  不加括号的
คℒ๓. ༗🍁:艾zug
Admin²⁰²⁰:
          let that= this;          setTimeout(() => {            that.TurnOnxxxx();          }, 2000);

-EOF-

AI助手支持GPT4.0