React-Router

React-Routerhtml

  React-Router的本质是根据当前location,决定是否绘制component。要使用React-Router有几个要点:react

  1)根结点必须是Router,且Router只能有一个子结点。git

  2)Router内随意旋转Route,Route根据当前location,决定是否绘制component。github

 

  The common low-level interface for all router components. Typically apps will use one of the high-level routers instead:web

  

  1)v4以上版本,须要经过createBrowserHistory创造history对象。已没有browserHistory这个定义。api

import { Router } from 'react-router'
import createBrowserHistory from 'history/createBrowserHistory'

const history = createBrowserHistory()

<Router history={history}>
  <App/>
</Router>

  2)A single child element to render. 只能有一个子结点。react-router

 

参考:https://reacttraining.com/react-router/web/api/Linkapp

相关文章
相关标签/搜索