简体   繁体   English

React 路由器将我重定向到 Hash 路由器,而不是返回到基础 url

[英]React router redirects me to Hash Router instead of going back to the base url

Hello I'm trying to redirect my link to one of my components, however I can't do it.您好,我正在尝试将我的链接重定向到我的一个组件,但是我做不到。

To explain, I have my HomePage which is my main page.解释一下,我有我的主页,这是我的主页。 It redirects to components through links.它通过链接重定向到组件。

MenuPage菜单页

<NavLink to="/administration/"> />Administration</NavLink>

Home page主页

<BrowserRouter>
       <Route path="/administration/" component={Administration} />
        <Route replace path="/settings/:ID" component={Settings} />
  </BrowserRouter>

I then use Hash Router to redirect to switches and to separate my data on the administration page.然后我使用 Hash 路由器重定向到交换机并在管理页面上分离我的数据。

Administration page管理页面

<HashRouter>
      <Menu>
        <MenuItem exact  to="/">Tous</MenuItem>
        <MenuItem   to="/avalider">À Valider</MenuItem>
        <MenuItem   to="/valides">Validés</MenuItem>
        <MenuItem   to="/encours">En Cours</MenuItem>
        <MenuItem   to="/terminés">Terminés</MenuItem>
        <MenuItem   to="/litiges">Litiges</MenuItem>
      </Menu>


      <Switch>
      <Route  exact path="/" component={Tous} />
      <Route  path="/avalider" component={Avalider} />
      <Route  path="/valides" component={Validés} />
      <Route  path="/encours" component={Encours} />
      <Route  path="/terminés" component={Terminés} />
      <Route  path="/litiges" component={Litiges} />
      </Switch>
    </HashRouter>

And then in my "All" component, I have my Navlink然后在我的“全部”组件中,我有我的导航链接

<NavLink  to={`/settings/${order.id}`} key={order.id} >

For the moment, my link redirects to目前,我的链接重定向到

localhost:3000/administration/#/settings/$ID本地主机:3000/administration/#/settings/$ID

What I would like from it would be我想从中得到什么

localhost:3000/settings/$ID本地主机:3000/设置/$ID

Thanks for your time.谢谢你的时间。

add ./ in your route在您的路线中添加./

 to={`./settings/${order.id}`

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM