【问题标题】:React Routing issue Redirect反应路由问题重定向
【发布时间】:2020-03-18 16:30:55
【问题描述】:

如何通过 onload 获取哈希位置

            <Redirect exact from="/:id" to="/user/1231231"/>
            <Route path="/user/:id" exact component={UserComponent}/>

【问题讨论】:

  • 如何通过history.push创建单独的组件来处理重定向和连接查询参数?

标签: reactjs react-native react-router


【解决方案1】:

我不知道您使用的是什么版本的软件包。但这里是基本的例子。试试去?profile=:id

https://codesandbox.io/s/react-router-stackoverflow-lchu9

gif

【讨论】:

  • 它给了我这个错误TypeError: Cannot read property 'pathname' of undefined我已经用我的包裹更新了我的问题谢谢
  • 没有理由不应该工作,你需要调试。还要考虑我使用的路由器版本与您不同。查看文档。
猜你喜欢
  • 1970-01-01
  • 2018-12-25
  • 1970-01-01
  • 2020-11-11
  • 1970-01-01
  • 1970-01-01
  • 2020-10-22
  • 2022-01-19
相关资源
最近更新 更多