vue create vite-vue2-demo // ... cd vite-vue2-demo npm i
npm i -D vite vite-plugin-vue2
index.html /public -> 根目录下,与package.json同级
<body> // ... <div id="app"></div> <script type="module" src="/src/main.js"></script> </body>
const router = new VueRouter({ mode: "history", // base: process.env.BASE_URL, base: import.meta.env.BASE_URL, routes, });
"script": { "serve": "vite", // ... }
大功告成,执行命令
npm run serve
原文:https://www.cnblogs.com/guxingzhe/p/14892187.html