为了账号安全,请及时绑定邮箱和手机立即绑定

在react-router v4中嵌套路由

在react-router v4中嵌套路由

拉丁的传说 2019-11-04 10:13:05
我已经在应用程序中将React Router升级到了版本4。但是现在我得到了错误Warning: You should not use <Route component> and <Route children> in the same route; <Route children> will be ignored此路由有什么问题?import {    Switch,    BrowserRouter as Router,    Route, IndexRoute, Redirect,    browserHistory} from 'react-router-dom'   render((    <Router history={ browserHistory }>        <Switch>            <Route path='/' component={ Main }>                <IndexRoute component={ Search } />                <Route path='cars/:id' component={ Cars } />                <Route path='vegetables/:id' component={ Vegetables } />            </Route>            <Redirect from='*' to='/' />        </Switch>    </Router>), document.getElementById('main'))
查看完整描述

3 回答

?
qq_遁去的一_1

TA贡献1725条经验 获得超7个赞

嵌套路由在版本react-router 4.x中不可用。这是一个直接来自react-router 文档的基本示例 ,说明如何在v4.x中嵌套secnarios。

查看完整回答
反对 回复 2019-11-04
  • 3 回答
  • 0 关注
  • 1723 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信