主要是 setInterval 这一函数在 ts 下的简单实现
export default class Test extends tsx.Component {
public timer: NodeJS.Timeout | null = null;
public mounted() {
this.timer = setInterval(
() =>
console.log("doSomething"),
10000,
)
}
public beforeDestroy() {
if(this.timer) clearInterval(this.timer)
// clearInterval(Number(this.timer))
}
}
Comments | NOTHING