NextJs 未找到页面每隔约 3 秒重新加载一次
P粉054616867
P粉054616867 2023-08-31 18:22:20
[React讨论组]
<p>我正在关注这个 https://nextjs.org/docs/app/api-reference/file-conventions/not-found</p> <p>但一切正常,但未找到的页面每秒都会重新加载。这是我的未找到页面代码</p> <pre class="brush:php;toolbar:false;">import Link from &quot;next/link&quot;; export default function NotFound() { return ( &lt;div className=&quot;overflow-hidden bg-white text-black md:py-20&quot;&gt; &lt;div className=&quot;container relative mx-auto px-4&quot;&gt; &lt;div className=&quot;grid grid-cols-1 items-center px-4 py-20 xl:py-10&quot;&gt; &lt;div&gt; &lt;h2 className=&quot;relative z-10 text-center text-6xl font-bold xl:text-9xl&quot;&gt; Oops! &lt;br /&gt; Page Not Found &lt;/h2&gt; &lt;span className=&quot;absolute left-0 top-0 w-full transform whitespace-nowrap text-[250px] font-extrabold text-gray-400 opacity-40 blur-[2px] md:-left-[5%] xl:text-[300px]&quot;&gt; ERROR 404 &lt;/span&gt; &lt;p className=&quot;mx-auto text-center text-base md:p-4 xl:w-2/3 xl:text-xl&quot;&gt; Don&amp;apos;t worry, though! Our team of skilled developers is constantly working to enhance your browsing experience. In the meantime, feel free to explore our other amazing content and discover exciting insights. &lt;br /&gt; If you believe you&amp;apos;ve reached this page in error, please double-check the URL or use the navigation links to find your way back to our website&amp;apos;s main sections. &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; ); }</pre></p>
P粉054616867
P粉054616867

全部回复(1)
P粉964682904

这是 Next.js 中的一个已知错误,已在 GitHub 上报告。显然,它只发生在开发模式(npm run dev)期间,但在生产模式(npm run build && npm start)中没有问题。

我注意到您正在使用 Link 组件,即 可能是问题

因此,删除 import Link from "next/link"; 应该会使其适合您,因为您没有使用它。

有些人还报告使用turbopack修复了该问题也是如此。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号