Nextjs链接标记指向同一页面会导致刷新 [英] Nextjs Link tag points to same page causes a Refresh
问题描述
如果用户在主页上,则单击标题菜单"中的主页"选项将刷新并加载同一页面.使用标题布局内的<Link as='/homepage' href='/landing'>Home Page</Link>
以及自定义服务器来处理所有URL请求.
If the user is on the Home page, clicking on the Home Page option in the Header Menu will cause a refresh and loads the same page. Using <Link as='/homepage' href='/landing'>Home Page</Link>
inside the Header Layout and also a custom server to server all the URL requests.
推荐答案
我遇到了完全相同的问题.对我来说,事实证明是bc我在页面的索引文件中使用getServerSideProps
.我在滥用它,因此可以用getStaticProps
代替它.检查您正在使用的nextjs数据获取功能是一个好主意. ( https://nextjs.org/docs/basic-features/data-fetching).
I was having this exact same issue. For me it turned out to be bc I was using getServerSideProps
in the page's index file. I was misusing it and was able to replace it with getStaticProps
, instead. Might be a good idea to inspect which of nextjs data fetching functions you are using. (https://nextjs.org/docs/basic-features/data-fetching).
这篇关于Nextjs链接标记指向同一页面会导致刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!