1、软件环境
➜ ~ node -v
v18.17.1
➜ ~ npm -v
10.0.0
➜ ~ vite -v
vite/4.4.9 darwin-arm64 node-v18.17.1
➜ ~ tsc -v
Version 5.2.2
安装依赖
node安装:https://nodejs.org/en/download
vite安装:sudo npm install vite -g
ts安装:sudo npm install typescript -g
工程初始化
➜ vue3-ts-vite-vant git:(main) npm init vite
Need to install the following packages:
create-vite@4.4.1
Ok to proceed? (y) y
✔ Project name: … vite-vue3-ts
✔ Select a framework: › Vue
✔ Select a variant: › TypeScript
Scaffolding project in /Users/szlsay/Documents/GitHub/vue3-ts-vite-vant/vite-vue3-ts...
Done. Now run:
cd vite-vue3-ts
npm install
npm run dev
效果
Pinia
npm install pinia -save
工程代码校验
采用volar,不再使用vetur
- props中type明确类型,并添加默认值
- 形参添加类型,不清楚的为any