Javascript 如何正确使用react路由器的嵌套路由?
我试图在Javascript 如何正确使用react路由器的嵌套路由?,javascript,reactjs,react-router,Javascript,Reactjs,React Router,我试图在/dashboard路径下使用react router获取嵌套UI,因此得到: <Route path={'/dashboard'} component={Components.Dashboard} onEnter={utils.onlyAfterLogin}> <Route path={'/tiendas'} component={Components.StoresIndex} /> </Route> 假设您使用
/dashboard
路径下使用react router获取嵌套UI,因此得到:
<Route
path={'/dashboard'}
component={Components.Dashboard}
onEnter={utils.onlyAfterLogin}>
<Route
path={'/tiendas'}
component={Components.StoresIndex} />
</Route>
假设您使用的是最新的react路由器版本(撰写本文时为2.0.1),那么应该这样使用它。 除非它是最上面的路由组件,否则不需要在路由前面加“/”前缀
<Route path="/" component={Root}>
<Route path="dashboard" component={Dashboard}>
<Route path="tiendas" component={Tiendas}/>
</Route>
</Route>
假设您使用的是最新的react路由器版本(撰写本文时为2.0.1),那么应该这样使用它。 除非它是最上面的路由组件,否则不需要在路由前面加“/”前缀
<Route path="/" component={Root}>
<Route path="dashboard" component={Dashboard}>
<Route path="tiendas" component={Tiendas}/>
</Route>
</Route>