React Router
React Router 介绍
react Router 是完整的 react 路由解决方案,它保持 UI 与 URL 同步,拥有简单的 API 与强大的功能例如代码缓冲加载、动态路由匹配、以及建立正确的位置过渡处理
安装
npm install --save react-router
使用时,路由器Router就是react的一个组件。
import { Router } from 'react-router';
render(<Router/>,document.getElementById('app'));
Router组件本身只是一个容器,真正的路由要通过Route组件定义。
import { Router,Route,hashHistory } from 'react-router';
render((
<Router history={hashHistory}>
<Route path="/" component={App}/>
</Router>
),document.getElementById('app'));
网站地址:https://reacttraining.com/react-router/
GitHub:https://github.com/ReactTraining/react-router
网站描述:React 路由管理