【发布时间】:2021-05-24 17:37:57
【问题描述】:
我为 60 秒的计时器编写了代码,但 setTimeout() 可以正常执行几分钟,但一段时间后它正在解析函数,但没有延迟,并且函数每秒都会被解析。
这里,this.rateCardTimerText 在第一次调用中初始化为零。
如果可用,请提供任何适当的解决方案,或者是否有任何替代方法可以实现它,然后请提及。
onChangeTimerChangeInfinity() {
let no = Number(this.rateCardTimerText)
if (no >= 100) {
no = 0
this.getCurrencyList()
}
else {
no += 1.66
}
this.rateCardTimerText = no
this.forceUpdate()
setTimeout(this.onChangeTimerChangeInfinity.bind(this), 1000)
}
【问题讨论】:
标签: javascript settimeout delay