【问题标题】:React Nested Router: Remove Parent Route from link反应嵌套路由器:从链接中删除父路由
【发布时间】:2021-07-29 00:42:42
【问题描述】:

所以,我一直在与react-router-dom 合作。我的问题是我正在使用嵌套路由。我想让它在 URL 中没有父路由的路由。 我当前的代码是。 <Route path= "/dashboard/some-page" component={someComponent}/> 而我想做的是 <Route path="/some-page" component={someComponent}/>.

【问题讨论】:

    标签: reactjs jsx react-router-dom


    【解决方案1】:

    目前,您不能。 react-router-dom 仅匹配完整路径。在即将发布的第 6 版中,他们添加了该功能,但目前仍处于测试阶段。这不是替代品的下降; API 已更改,因此需要进行一些重组。

    https://reacttraining.com/blog/react-router-v6-pre/#nested-routes-and-layouts

    【讨论】:

      猜你喜欢
      • 2021-08-11
      • 2019-02-18
      • 1970-01-01
      • 2019-04-06
      • 2016-08-18
      • 1970-01-01
      • 2021-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多