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
相关推荐
小付同学呀41 分钟前
C语言学习(八)——C判断(switch语句)
c语言·学习·算法
科技林总1 小时前
【系统分析师】11.6 软件需求确认和验证
学习
ZTLJQ2 小时前
深入理解Autoencoder:无监督学习的异常检测与数据压缩利器
学习
夏星印2 小时前
argparse解析器参数详解
经验分享·笔记·python·学习·argparse
Shining05962 小时前
AI编译器系列(二)《AI 编译器中的前端优化》
人工智能·学习·其他·学习方法·infinitensor
码喽7号2 小时前
springboot学习四:RESTful风格+swagger
spring boot·学习·restful
weixin_458872613 小时前
东华复试OJ二刷复盘8
学习
海奥华23 小时前
Rust初步学习
开发语言·学习·rust
王知无(import_bigdata)4 小时前
一个极简的AI Agentic Engineering技术栈学习路线
人工智能·学习