使用React-router + webpack 做按需加载,基本和官网的Demo差不多,但是报错,
报错信息

不知道哪里的错误,附上我的代码,
//route.js
const Com1 = {
path:'com1',
getComponent(nextState,cb){
require.ensure([],(require)=>{
return cb(null,require('../com1')).default
})
}
}
...
export default {
Com1:Com1,
Com2:Com2,
Com3:Com3
}
import {Com1,Com2,Com3} from './Components/config/route';
const rootRoute = {
path: '/',
component: require('./Components/main').default,
childRoutes:[{
// path:'/',
// component: require('./Components/main').default,
childRoutes:[
Com1,
Com2,
Com3,
]
}]
}
let root = document.getElementById('app');
render(
//
,root);
这样就会报一个warning一个错误,望指点!
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
看代码你像是写了两份的childRoutes,然后中间又注释掉了一份,然后就会产生中间的
这部分的第二行找不到对应的path,报出warning。
删掉下面的childRoutes似乎就可以了。
只是猜测,可能不对哈。
貌似是你的第二个childRoutes,没有给path,和component,你加上试一下应该就可以了。