# VSCode支持TypeScript语法提示

安装TypeScript Vue Plugin (Volar) (opens new window)插件

并设置为Takeover 模式

具体见vue3 文档 (opens new window)

之后就reload 项目就可以尽情使用typescript的语法提示了

# 在Vue3中使用CSS module

可以通过两种方式:

1.一种是在setup或render中定义

const $style = useCssModule()
// 默认情况下, 返回 <style module> 的 class
useCssModule()

// 具名情况下, 返回 <style module="classes"> 的 class
useCssModule('classes')
1
2
3
4
5
6

2.另一种是在style中使用module声明

<template>
  <div :class="mystyle.red">{{ count }}</div>
</template>

<style module="mystyle">
.red {
  color: red;
}
</style>
1
2
3
4
5
6
7
8
9

添加module属性,自动注入

# 在jsx中使用css module

使用vite

import styles from './MyButton1.module.css'

render() {
  <span class={styles.blue}>{this.count}</span>
}
1
2
3
4
5

添加类名自动提示

typescript-plugin-css-modules