18 react-router

react-router: 它通过管理 URL,实现组件的切换和状态的变化,开发复杂的应用几乎肯定会用到。

用法:子路由也可以不写在Router组件里面,单独传入Router组件的routes属性。

        组件有一个参数history,它的值hashHistory表示,路由的切换由URL的hash变化决定,即URL的#部分发生变化。举例来说,用户访问http://www.example.com/,实际会看到的是http://www.example.com/#/

<Router routes={routes} history={browserHistory}/>
 
export default (
      <Router path="/(**/)">
       <IndexRoute component={aaa}/>
       <Route path="/aaa" component={aaa}/>
    </Router>
   );
原文地址:https://www.cnblogs.com/liufei1983/p/14538860.html