【发布时间】:2018-02-24 10:48:33
【问题描述】:
我有一个要求,我想在不同的路线上呈现不同的组件 所以
- http://localhost/page1 应该渲染第 1 页
- http://localhost/page2 应该渲染 Page2
- http://localhost/page3 应该渲染 Page3
- http://localhost/ 应该渲染动物
为此使用以下配置吗?这是正确的还是社区推荐其他东西用于此?
import {Route, Switch} from 'react-router';
import {ConnectedRouter} from 'react-router-redux';
<ConnectedRouter history={app.history}>
<div>
<Route exact path="/page1" component={Page1} />
<Route exact path="/page2" component={Page2} />
<Route exact path="/page3" component={Page3} />
<Route exact path="/:animal?" component={Animal} />
</div>
</ConnectedRouter>
【问题讨论】:
标签: reactjs react-router react-router-v4 react-router-redux