【问题标题】:React Router Redirected too many times反应路由器重定向太多次
【发布时间】: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


【解决方案1】:

通常我只设置&lt;Redirect to="/" /&gt;(没有额外的参数),它工作正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-22
    • 2017-10-22
    • 1970-01-01
    • 2018-08-13
    • 1970-01-01
    • 2018-12-25
    • 2021-09-29
    相关资源
    最近更新 更多