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
相关推荐
白小沫1 小时前
TortoiseSVN是什么?
学习
weixin_451431561 小时前
【学习笔记】微博视频页面ajax请求与响应数据分析
笔记·学习·音视频
清辞8532 小时前
尾盘选股法程序开发学习初期
学习
Century_Dragon3 小时前
让实训“活”起来——信息化综合实训考核平台助力汽车专业教学
学习
快乐得小萝卜3 小时前
OpenVLA 论文精读笔记
笔记
nashane3 小时前
HarmonyOS 6学习:PanGesture手势驱动月亮半圆轨迹“滚动”术
学习·harmonyos 5
叶~小兮4 小时前
K8S进阶核心综合学习笔记(持久化存储+特殊容器+调度管理)
笔记·学习·kubernetes
li星野4 小时前
位运算 & 数学 & 高频进阶九题通关(Python + C++)
c++·python·学习·算法
Skylwn5 小时前
保姆级教程之将 GitHub Models 接入 NewAPI
笔记·github
脆皮炸鸡7555 小时前
库制作与原理~动态链接
linux·开发语言·经验分享·笔记·学习方法