【发布时间】:2021-08-11 00:56:25
【问题描述】:
您好,我如何渲染实际上在不同组件上分离的路由,例如我的仪表板有 2 条路由,里面有 2 个组件,而我的 App.js 拥有所有其余的。 而且我无法从仪表板内部重定向到 /login,它不会从仪表板内部重定向(我使用 history.push("/login"))
更新:
我的代码是这样的 dashboard.js 组件
<Router>
....mycomponent
<switch>
<Route path="/cutomers"><CutomersComponent><Route>
<Route path="/sales"><SalesComponent><Route>
</switch>
</Router>
app.js 组件
<Router>
....mycomponent
<switch>
<Route path="/login"><Login><Route>
<Route path="/dashbord"><Dashbord><Route>
</switch>
</Router>
【问题讨论】:
-
请显示您目前尝试过的代码
-
我的代码现在更新了
-
这能回答你的问题吗? Nested routes with react router v4 / v5
标签: reactjs react-router