添加跳转的父级组件AdminIndex,注意父级组件不能写exact,不然匹配不到子路由
import AdminIndex from './AdminIndex' <Router> <Route path="/index/" component={AdminIndex}></Route> </Router>
在父级组件中嵌套路由,注意渲染的子路由要加上exact
{/* 注意exact*/} import AddArticle from './AddArticle' import ArticleList from './ArticleList' <Route exact path="/index/" component={ArticleList} /> <Route exact path="/index/add" component={AddArticle} /> <Route exact path="/index/list" component={ArticleList} />
本文作者为gengboxb,转载请注明。