Resource
Rule
1、通配符匹配
? *表示任意字符 ** 表示任意路徑 ()表示可以省略或匹配
2、:param 和 ?key=value
? 可以用通過props.param獲取到
? 可以用props.location.query.key獲取到
3、路徑同時匹配只匹配其一
? 因此,帶參數(shù)的路徑一般要寫在路由規(guī)則的底部。
4、IndexRoute
? 顯示指定默認路由,當有子路由的時候,匹配子路由的組件
? layout:
? ? ? Router
? ? ? ? IndexRoute component={default}
? ? ? ? route path="children" component={child}
5、Redirect 組件
? 組件用于路由的跳轉(zhuǎn),即用戶訪問一個路由,會自動跳轉(zhuǎn)到另一個路由
? 從屬于route,只有from to,沒由componente
6、函數(shù)跳轉(zhuǎn)
? 使用context對象: this.props.router.push(path)
7、onEnter
? layout: onEnter={(routeMsg, replace) => replace('path') }
8. lifecycle
? 在路徑上的component沒有被移除的會componentWillRecieveProps, 被激活的會componentDidMount
9. 激活路由
? 只會使相對應(yīng)的組件激活,才不是整個頁面切換呢