添加babel插件
packjson.json
"babel-plugin-syntax-dynamic-import": "6.18.0",
.babelrc
"plugins": [ "syntax-dynamic-import" ],
webpack 配置
webpack.base.conf.js
output: { chunkFilename: "chunk[id].js?[chunkhash]" },
router
index.js
const home = () => import("@/pages/public/home"); { path: "home", component: home },