【发布时间】:2021-07-01 17:14:41
【问题描述】:
我使用数组为同一个组件声明了两个不同的路径。
<Router>
<HeaderBN/>
<Switch>
<Route exact path="/" component={Home}/>
<Route path={["/about", "/aboutus"]} component={About}/>
</Switch>
</Router>
但现在我想如果有人访问“/about”路径,那么他会自动重定向到“/aboutus”路径。我怎样才能做到这一点?我阅读了 react-router-dom 文档,但没有找到解决此问题的任何方法。
【问题讨论】:
标签: reactjs react-router react-hooks