效果
正文
1.使用nvm管理nodejs版本
公司项目是用vue2开发的,node版本是10.15.0
vue3的node版本要求在14.0以上。
可在点此在github上下载最新版本nvm
- nvm-noinstall.zip:绿色免安装版,但使用时需进行配置。
- nvm-setup.zip:安装版,推荐使用。
- Source code(zip):zip压缩的源码。
- Sourc code(tar.gz):tar.gz的源码,一般用于linux系统。
在安装适用于Windows的NVM之前,需要卸载任何现有的node.js版本
-
安装
-
选择nvm安装路径
-
nodejs安装路径
-
环境变量
-
验证是否成功
-
安装指定版本的nodejs
-
查看已经安装的版本
-
使用14.17.6 node版本
2.使用闪电般的vite构建项目
yarn create vite <project-name> --template vue
cd <project-name>
yarn
yarn dev
如果没有yarn,需要安装yarn,可以自己百度一下,不会的私聊我。
3.使用vue-router、vuex
yarn add vue-router@next vuex@next
src下创建 store/index.js
src 目录下建立 router/index.js
修改main.js
import router from "./router";
app.use(router)
4.使用vant3
yarn add vant@next
修改main.js
import Vant from 'vant'
import 'vant/lib/index.css'
app.use(Vant)