【发布时间】:2022-12-14 20:27:26
【问题描述】:
为什么这只执行两次?
class TestClass {
runPeriodically() {
console.log('hello!');
setTimeout(this.runPeriodically, 1000);
}
}
let test = new TestClass();
test.runPeriodically();
【问题讨论】:
-
要定期运行,请使用
setInterval(this.runPeriodically, 1000);
标签: javascript