使用npm init vite <项目名称>创建项目
1. vue2.x项目的package.json打开,复制
"dependencies": { "core-js": "^3.6.5", "vue": "^3.0.0", "vue-router": "^4.0.0-0", "vuex": "^4.0.0-0" },
2.把dependencies替换到vite项目的package.json中
3.npm i
4.把vue2.x项目的src目录整体复制到vite中
5.npm install vite-plugin-vue2 -D
配置:vite.config.js
import { defineConfig } from 'vite' import { createVuePlugin } from 'vite-plugin-vue2'
export default defineConfig({ plugins: [ createVuePlugin(/* options */) ], })
**npm地址:vite-plugin-vue2 - npm
6. npm run dev运行的时候会报错
-
安装 npm i vue-template-compiler
-
修改错误 可能会有报错的内容:@/env是没有,进行修改就可以了
-