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
相关推荐
AI视觉网奇1 小时前
nohup 学习笔记
笔记·学习
一个尚在学习的计算机小白1 小时前
大模型学习笔记
笔记·学习
高木的小天才2 小时前
HarmonyOS 页面跳转新方案:HMRouter 路由框架全方位使用指南与实践案例
华为·typescript·harmonyos
MUTA️2 小时前
《CogAgent: A Visual Language Model for GUI Agents》论文精读笔记
人工智能·笔记·语言模型·多模态
Asu52023 小时前
思途spring学习0807
java·开发语言·spring boot·学习
胤祥矢量商铺4 小时前
菜鸟笔记007 [...c(e), ...d(i)]数组的新用法
c语言·开发语言·javascript·笔记·illustrator插件
泽虞4 小时前
C语言深度语法掌握笔记:底层机制,高级概念
java·c语言·笔记
董莉影5 小时前
学习嵌入式第二十二天
数据结构·学习·算法·链表
尘心不灭5 小时前
Spring Boot 项目代码笔记
spring boot·笔记·后端