我的超时有问题,我在一个对象中声明了它们,但无法清除它,它只是告诉我在尝试将其记录在控制台中时未定义。有一种特殊的方法吗?
我试图这样声明它: this.disapear = window.setTimeout(this.endgame,this.timer); 但这无济于事。
constructor() {
this.elem.addEventListener('click', this.remove);
this.disappear = setTimeout(this.endgame, this.timer);
}
remove() {
clearTimeout(this.disappear);
}
这里是个主意:我单击该元素(它显示在导航器中),该元素随着超时而消失。该元素实际上消失了,但是超时仍然存在。
感谢您的时间!