gpt4 book ai didi

next.js - 为什么预取不适用于 Next.js 中的 组件?

转载 作者:行者123 更新时间:2023-12-02 18:53:00 25 4
gpt4 key购买 nike

我读了很多博客,每个人都提到 Next.js 会预取链接,但它对我不起作用。

这是我的 chrome 网络选项卡: enter image description here

那是我试过的代码:

import  Link from 'next/link' 

export default function Home() {
return (
<div >
<Link href="/home">
<a>Home</a>
</Link>
<Link href="/About/about">
<a>About</a>
</Link>
</div>
)
}

最佳答案

Next.js 不会在开发模式下预取页面,预取是仅限生产的功能。

尝试在生产模式下运行您的应用。

npm run build && npm run start

关于next.js - 为什么预取不适用于 Next.js 中的 <Link> 组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66514628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com