修改前的加载时间是37485ms
npm install babel-plugin-dynamic-import-node --save-dev
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"],
//下面的代码是需要加上的
"env": {
"development": {
"plugins": ["dynamic-import-node"]
}
},
"comments": false
}
item.component = () =>import (`@/views/${item.name}`);
修改后的写法
item.component = resolve => (require([`@/views/${item.name}`], resolve));
本文到此结束,希望对你有帮助
如果还有什么疑问或者建议,可以多多交流,原创文章,文笔有限,才疏学浅,文中若有不正之处,万望告知