我如何计算该页面已加载在React中的多少次?

发布于 2025-02-10 12:03:42 字数 116 浏览 0 评论 0 原文

我想计算一个页面加载多少次。 我认为需要使用useFect(),但我不知道页面加载的依赖性是什么。

例如,一旦您在浏览器上点击“刷新”,则计数应增加1。 而且它不会属于无限的循环。

谢谢您。

I would like to count how many times a page is loaded.
I think useEffect() needs to be used but I have no idea what would be the dependency for page load.

For example, once you hit 'refresh' on your browser, the count should be increased by 1.
And it doesn't fall into an infinite loop.

Thank you in Advanced.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰◇生如夏花灿烂 2025-02-17 12:03:42

您可以在页面正文中使用Console.Count()方法:

You can use the console.count() method in the body of the page:
https://developer.mozilla.org/en-US/docs/Web/API/console/count

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文