react 学习笔记

1.Router

1.1 Histories

 React Router 是建立在 history 之上的。一个 history 知道如何去监听浏览器地址栏的变化, 并解析这个 URL 转化为 location 对象, 然后 router 使用它匹配到路由,最后正确地渲染对应的组件。

 

常用的 history 有三种形式, 但是你也可以使用 React Router 实现自定义的 history。

1.2 IndexRoute

  IndexRoute 代表Route 级别的默认路径,同时,需要包在Route内,目录结构如下:

<Router history={browserHistory}>
    <Route path="/" component={App}>
      {/*IndexRoute 代表默认路由,如 url 为:  localhost:8080/   ,默认读取Respos;如果 url为: localhost:8080/about 读取About component ;
    如果不指定 IndexRoute ,默认为undefined, 访问localhost:8080/ 将不显然任何component
*/} <IndexRoute component={Repos} /> <Route path="/about" component={About}/> </Route> </Router>

 1.3 Params

   

 

  

 

posted @ 2016-12-29 16:12  rengised  阅读(138)  评论(0编辑  收藏  举报