angular中clearTimeout不生效的问题

205

之前使用setTimeout、clearTimeout都是正常的,但这次却无法清除定时器了

右键跳转到定义,发现使用的是:

declare function clearTimeout(timeoutId: NodeJS.Timer): void;

这是node端用的定时器。

正确应该调用的是window.clearTimeout,这是前端用的定时器

原因:

安装了@types/node所致

解决办法:

使用window.setTimeout和window.clearTimeout

留下一个答复

Please enter your comment!
Please enter your name here