我是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>