nuw*_*way 9 javascript reactjs webpack react-router webpack-dev-server
我有一个基于http://moduscreate.com/code-splitting-for-react-router-with-es6-imports/文章的应用程序.我添加了一些子路由,现在我的路由器配置是这样的:
function errorLoading(err) {
console.error('Dynamic page loading failed', err);
}
function loadRoute(cb) {
console.log('load route called');
return (module) => cb(null, module.default);
}
const obj = {
component: App,
childRoutes: [
{
path: '/',
getComponent(location, cb) {
System.import('pages/Home')
.then(loadRoute(cb))
.catch(errorLoading);
}
},
{
path: '/gsgs',
getComponent(location, cb) {
System.import('pages/Gsgs')
.then(loadRoute(cb))
.catch(errorLoading);
},
childRoutes: [
{
path: 'go',
getComponent(location, cb) {
System.import('pages/Gsgs/Home.js')
.then(loadRoute(cb))
.catch(errorLoading);
},
}
]
},
{
path: '/about',
getComponent(location, cb) {
System.import('pages/About')
.then(loadRoute(cb))
.catch(errorLoading);
}
},
]
};
Run Code Online (Sandbox Code Playgroud)
/ index,/ about和/ gsgs routes触发动态代码加载就好了.但/ gsgs/go会触发404
bundle.js:2动态页面加载失败错误:加载块0失败.(...)
我究竟做错了什么?我正在使用
Run Code Online (Sandbox Code Playgroud)"webpack": "^2.1.0-beta.4", "webpack-dev-server": "^2.0.0-beta"
| 归档时间: |
|
| 查看次数: |
1896 次 |
| 最近记录: |