【发布时间】:2019-09-18 22:14:19
【问题描述】:
拥有以下图片及其各自的html:
<nav className="navigation">
<div className="navigation-first">
<div className="navigation-container">
<Link to="/" activeClassName="active">Dashboard</Link>
<Link to="/work" activeClassName="active">Work</Link>
<Link to="/profile" activeClassName="active">My profile</Link>
<Link to="/account" activeClassName="active">Account</Link>
</div>
</div>
<div className="navigation-second">
<div className="navigation-container">
<Link to="/work/jobs" activeClassName="active">Job search</Link>
<Link to="/work/pools" activeClassName="active">Talent pools</Link>
</div>
</div>
</nav>
我希望第二部分是动态的。假设对于每个上层菜单,我想要有各种子菜单。看看我目前拥有的路由器:
<Router history={browserHistory}>
<Route component={MainLayout}>
<Route path="/" component={Home} />
<Route path="work">
<Route path="jobs">
<Route component={SearchLayoutContainer}>
<IndexRoute component={JobContainer} />
</Route>
</Route>
<Route path="pools">
<Route component={SearchLayoutContainer}>
<IndexRoute component={PoolContainer} />
</Route>
</Route>
</Route>
</Route>
</Router>
顺便说一句,导航来自嵌套在视图中的组件,可以吗?现在我有这个结构:
欢迎提供任何信息。提前非常感谢。
PD:我已经阅读了 react-router 文档。
【问题讨论】:
标签: reactjs nested navigation react-router