程序员饥人谷技术博客

React Router and Lifecycle

2017-07-15  本文已影响0人  柏龙

源码查看

使用终端

url地址

组件的生命周期

路由

import { Router, Route, hashHistory, Link, IndexRoute, Redirect } from 'react-router'

相关代码

<Router history={hashHistory}>
    <Route path="/" component={App}>
        <IndexRoute component={Home} />
        <Route path="article" component={Article}>
            <IndexRoute component={ShowIndex} />
            <Route path="/shows/:id" component={Show}
                onEnter={handleEnter}
                onLeave={handleLeave}
            />
            <Redirect from="shows/:id" to="/shows/:id"/>
        </Route>
    </Route>
</Router>
上一篇 下一篇

猜你喜欢

热点阅读