本来打算用vue3写,用的vue-cli4,后来没有用vue3,里面是vue2的写法,下面是router.js喝vue.config.js,打包之后js并没有分割,求解答
{
path: "name1",
component: ()=> import(/* webpackChunkName: "name1" */ '../views/name1.vue')
},
{
path: "name2",
component: ()=> import(/* webpackChunkName: "name2" */ '../views/name2.vue')
},
...
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes,
});
export default router;
// vue.config.js如下:
const express = require('express')
const app = express()
var apiRoutes = express.Router();
module.exports = {
lintOnSave: false,
publicPath: '/admin',
productionSourceMap: false,
}
安装 "@babel/plugin-syntax-dynamic-import"之后就可以了