Next.js从/重定向到另一个页面

问题描述 投票:1回答:2

例如,我是Next.js]的新手,我想知道如何从起始页(/)重定向到/ hello-nextjs。用户加载页面后,确定路径是否=== /重定向到/ hello-nextjs

react-router

中,我们做类似的事情:
<Switch>
  <Route path="/hello-nextjs" exact component={HelloNextjs} />
  <Redirect to="/hello-nextjs" /> // or <Route path="/" exact render={() => <Redirect to="/hello-nextjs" />} />
</Switch>

例如,我是Next.js的新手,我想知道如何从起始页(/)重定向到/ hello-nextjs。用户加载页面后,确定路径是否=== /重定向到/ hello-nextjs在...

html reactjs routing react-router next.js
2个回答
0
投票

next.js中,您可以使用Router重定向:


0
投票

有三种方法。

© www.soinside.com 2019 - 2024. All rights reserved.