【发布时间】:2019-08-24 08:49:52
【问题描述】:
我有以下Router.jsx,我想要完成的是将任何通配符重定向回根级别(Home)。
即http://xxxxxxx.com/randomPath 应该重定向到 -> http://xxxxxxx.com/
<Switch>
<Route exact path="/" component={Home} />
<Route path="/home" component={Home} />
<Route path="/faq" component={Faq} />
<Route path="/more" component={Faq} />
<Route path="/signup" component={SignUp} />
<Route path="/legal" component={Legal} />
<Route path="/ugc" component={Ugc} />
<Route path="/pricing" component={Pricing} />
<Redirect from="*" to='/' />
</Switch>
但是,在测试时,我得到:ERR_TOO_MANY_REDIRECTS
感谢您的帮助,在此先感谢!
【问题讨论】:
-
是 Home 组件重定向到
/home/而不是/home?
标签: reactjs redirect react-router