我目前正在尝试将react-react从v3迁移到v4,但我无法完全掌握新概念,我的旧反应路由器v3代码看起来像这样,有人可以看看并给我一些提示吗? 谢谢! Router history={ browserHistory } Route path="/
谢谢!
<Router history={ browserHistory }> <Route path="/" component={ App }> <IndexRoute name="index" component={ Index } /> <Route name="documents" path="/documents" component={ Documents } onEnter={ authenticate } /> <Route name="newDocument" path="/documents/new" component={ NewDocument } onEnter={ authenticate } /> <Route name="editDocument" path="/documents/:_id/edit" component={ EditDocument } onEnter={ authenticate } /> <Route name="viewDocument" path="/documents/:_id" component={ ViewDocument } onEnter={ authenticate } /> <Route name="login" path="/login" component={ Login } /> <Route name="recover-password" path="/recover-password" component={ RecoverPassword } /> <Route name="reset-password" path="/reset-password/:token" component={ ResetPassword } /> <Route name="signup" path="/signup" component={ Signup } /> <Route path="*" component={ NotFound } /> </Route> </Router>不要筑巢路线.
保留这一部分
<Router history={ browserHistory }> <Route path="/" component={ App } /> </Router>
并将所有嵌套移动到< App /> (见here). react-router-v4也没有< IndexRoute />的概念. (见here).
看看documentation,真是不可思议.