vue路由懒加载之后页面没有引入打包后的路由文件,导致页面空白
webpack
output: {
path: path.resolve(__dirname, './dist'),
filename: 'js/[name].bundle.js',
chunkFilename: 'js/[name].[hash:8].js',
},
router.js
Vue.use(VueRouter)
const routerLazyLoad = filename => () => () => import(
/* webpackChunkName: "[request]" */`./components/${filename}.vue`
)
module.exports = new VueRouter({
routes: [
{
path: '/', redirect: '/home'
},
{
path: '/home', component: routerLazyLoad('Home')
},
{
path: '/login', component: routerLazyLoad('Login')
},
{
path: '/seniority', component: routerLazyLoad('Seniority')
},
{
path: '/seniorityAll', component: routerLazyLoad('SeniorityAll')
}
]
})
而且还发现多打包了两个子组件,tabbar和toast,难道是只要在上述被懒加载的组件中引用过就会被打包吗?
今天我把output中的chunkFilename注释掉了,发现依然会打包路由文件... 很懵逼
解决了...
原来是我的箭头函数写的有问题... 对箭头函数理解的还是太浅了...
退一步就解决了..