动态导入文件报错,按照错误提示安装了插件,但未果,最后查到一个可行方案,记录如下:
报错
ERROR in ./src/router.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: D:\practice\vue-pro\webpack-vue-create\src\router.js: Support for the experimental syntax 'dynamicImport' isn't currently enabled (19:13):
解决方案
一:安装插件babel-plugin-dynamic-import-webpack
npm install babel-plugin-dynamic-import-webpack --save-dev
二:在vue工程的配置文件package.json下进行插件的配置,如下
"babel": {
"plugins": ["@babel/plugin-syntax-dynamic-import"]
}