reactjs - React 哈希路由和子路由

标签 reactjs redux react-router

例如,我当前有路线结构 #/home #/仪表板

但是我如何实现子路由或子路由,例如

#/home/dashboard

<HashRouter>
              <main className="h-100">
                <Switch>
                  <Route exact path='/home' component={Login} />
                  <Route path='/dashboard' component={Dashboard} />
                </Switch>
              </main>
            </HashRouter>

最佳答案

例如,您可以简单地将路由更改为子路由

<Route exact path='/home/subroute' component={Login} />

关于reactjs - React 哈希路由和子路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52938227/

相关文章:

javascript - 如何从多个子组件获取表单值?

reactjs - 如何让 CSS 模块与 Reactstrap cssModule propType 一起工作?

reactjs - React TypeScript将函数传递给子组件

javascript - React Native、Redux 和 Fetch : "Possible Unhandled Promise Rejection (id: 0)"

javascript - TypeError : Cannot read property 'type' of undefined functional components

reactjs - 使用react-router-dom时如何避免 'Function components cannot be given refs'?

javascript - ReactJS,Javascript,使用状态更改的导入函数的正确方法

javascript - ReduxThunk 如何将 Action 数据传递到原始状态?

javascript - 如何在 Ruby on Rails 应用程序中接受(并解析)www-url 编码的数据?

javascript - 如何使链接适合其内部的组件?