Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useInterval,在页面最小化,或者切换到其他页面的时候,如何防止定时器暂停啊。 #2612

Open
anyone0034 opened this issue Jul 29, 2024 · 1 comment

Comments

@anyone0034
Copy link

我现在碰到的问题,当页面切换的时候,原来的定时器就会暂停。

@crazylxr
Copy link
Collaborator

crazylxr commented Aug 5, 2024

这个跟浏览器的策略有关系,在资源不足的情况下就是会停掉不活跃的定时器,不好解决,如果是强诉求,可以尝试开一个 webworker ,worker 去执行定时器,然后把回调通过 postMessage 的方式发给主页面。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants