【发布时间】:2020-04-14 20:03:33
【问题描述】:
我有这个组件结构:
我需要基于 2 个不同的路由在
我使用:"react-router-dom": "^5.1.2"
,并且看到一些帖子在谈论使用IndexRoute和props.children,但是IndexRoute无法从react-router-dom中解决,似乎在版本5中被删除了。
我的路由器(BrowserRouter)长这样:
<Router basename={process.env.REACT_APP_ROUTER_BASE || '/MyApp'}>
<Switch>
<Route path="/" exact component={HomePage} />
{/*<IndexRoute component={ProjectsList} /> // The component to send to HomePage's `props.children` when route is '/'*/}
<Route path="/login" component={Login} />
<Route path="/editProject" component={ProjectEditor} />
{/*<Redirect path="*" to="/" />*/}
</Switch>
</Router>
一开始
但是从ProjectsList中需要编辑一个项目,所以这次需要在
更新
更详细的结构:
【问题讨论】:
标签: reactjs react-router