相关疑难解决方法(0)

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

我是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>
Run Code Online (Sandbox Code Playgroud)

html routing reactjs react-router next.js

55
推荐指数
11
解决办法
13万
查看次数

标签 统计

html ×1

next.js ×1

react-router ×1

reactjs ×1

routing ×1