Vite+Typescript+Vue3学习笔记

Vite+Typescript+Vue3学习笔记

1、项目搭建

1.1、创建项目(yarn)

shell 复制代码
D:\WebstromProject>yarn create vite
yarn create v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Installed "create-vite@4.4.1" with binaries:
      - create-vite
      - cva
√ Project name: ... vite-project
√ Select a framework: >> Vue
√ Select a variant: >> TypeScript

Scaffolding project in D:\WebstromProject\vite-project...

Done. Now run:

  cd vite-project
  yarn
  yarn dev

Done in 14.81s.

1.2、vite-env.d.ts

vite使用的是ts,不识别.vue后缀的文件,需在vite-env.d.ts配置下

tsx 复制代码
/// <reference types="vite/client" />
declare module "*.vue" {
    import { DefineComponent } from "vue"
    const component: DefineComponent<{}, {}, any>
    export default component
}

1.3、常用依赖

1、@types/node

ts需安装node的类型,否则使用node相关会提示找不到

shell 复制代码
# @types/node
yarn add -D @types/node

2、auto-import

用于简化Vue3中ref、reactive**、**watch和UI组件的导入

shell 复制代码
# unplugin-vue-components、unplugin-auto-import
yarn add -D unplugin-vue-components unplugin-auto-import

3、sass

shell 复制代码
# sass
yarn add -D sass

4、vue-router

shell 复制代码
# vue-router
yarn add vue-router@4
相关推荐
Promise48521 小时前
贝尔曼公式的迭代求解笔记
笔记·算法
Freshman小白1 天前
《生活英语读写》2025学堂在线网课答案(全部作业题)
爬虫·学习·答案
锦锦锦aaa1 天前
【layout理解篇之:mos电阻】
经验分享·笔记
zore_c1 天前
【C语言】带你层层深入指针——指针详解2
c语言·开发语言·c++·经验分享·笔记
koo3641 天前
pytorch深度学习笔记
pytorch·笔记·深度学习
m0_488913011 天前
小白也能懂!RAG技术让AI告别知识滞后,收藏学习
人工智能·学习·langchain·大模型·ai大模型·rag·大模型学习
眠晚晚1 天前
API攻防&系统攻防笔记分享
笔记·web安全·网络安全
石像鬼₧魂石1 天前
常用的安全审计工具可以用于靶机学习
学习·安全
2301_764441331 天前
三维建筑非法入侵情景推演
python·学习·算法
uxiang_blog1 天前
Linux学习之旅8
linux·运维·学习