react+react-redux demo 连载

原创 we1312331 随笔 好东西要分享 171阅读 2017-05-12 11:42:17 举报

import React from "react";
import {browserHistory, IndexRoute, Redirect, Route, Router} from "react-router";
//引入app
import app from "../pages/app.jsx";
//引入home 页面
import pageHome from "../pages/home.jsx";
//webpack会打包成chunk包 在进入album时去加载
const pageAlbum = (location, cb) => {
require.ensure([], require => {
cb(null, require('../pages/album.jsx').default)
}, 'pageAlbum')
};

更多资料每日分享加群 120342833 验证回答 ZZ
...
//定义路由 首先加载 app
//然后根据正则去匹配path来实现路由页面
const RouteConfig = (
<Router history={browserHistory}>
<Route path="/" component={app}>
<IndexRoute component={pageHome}/>
<Route path="home" component={pageHome}/>
<Route path="album" getComponent={pageAlbum}/>
<Route path="feedback" getComponent={pageFeedback}/>
<Route path="blist" getComponent={pageBlogList}/>
<Route path="bdetail" getComponent={pageBlogDetail}/>
<Redirect from='*' to='/'/>
</Route>
</Router>
);

export default RouteConfig;

评论 ( 0 )
最新评论
暂无评论

赶紧努力消灭 0 回复