Skip to content

Commit a25d358

Browse files
committed
docs: use defineVaporComponent instead of defineComponent
1 parent b2ddc24 commit a25d358

File tree

6 files changed

+30
-42
lines changed

6 files changed

+30
-42
lines changed

docs/features/macros.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22

33
A collection of macros for JSX. They are need to manually enabled by set `macros` to `true`.
44

5-
| Directive | Vue | Volar |
6-
| :---------------: | :----------------: | :----------------: |
7-
| `defineComponent` | :white_check_mark: | :white_check_mark: |
8-
| `defineModel` | :white_check_mark: | :white_check_mark: |
9-
| `defineSlots` | :white_check_mark: | :white_check_mark: |
10-
| `defineExpose` | :white_check_mark: | :white_check_mark: |
11-
| `defineStyle` | :white_check_mark: | :white_check_mark: |
12-
135
## Setup
146

157
::: code-group
@@ -64,7 +56,9 @@ export default {
6456

6557
:::
6658

67-
## defineComponent
59+
## defineComponent | defineVaporComponent
60+
61+
`defineComponent` is used to define Virtual DOM components, and `defineVaporComponent` is used to define Vapor components.
6862

6963
### Options
7064

@@ -82,12 +76,12 @@ VueJsxVapor({
8276
```
8377

8478
- Support `await` keyword.
85-
- Automatically collects used props to the defineComponent's props option.
79+
- Automatically collects used props to the defineVaporComponent's props option.
8680

8781
```tsx twoslash
88-
import { defineComponent, nextTick, Suspense, useAttrs } from 'vue'
82+
import { defineVaporComponent, nextTick, Suspense, useAttrs } from 'vue'
8983

90-
const Comp = defineComponent(
84+
const Comp = defineVaporComponent(
9185
async (props: {
9286
foo?: string
9387
bar?: string
@@ -113,8 +107,8 @@ export default () => (
113107
::: details Compiled Code
114108

115109
```tsx
116-
import { defineComponent, useAttrs, withAsyncContext } from 'vue'
117-
defineComponent(
110+
import { defineVaporComponent, useAttrs, withAsyncContext } from 'vue'
111+
defineVaporComponent(
118112
async (props) => {
119113
let __temp, __restore
120114
;([__temp, __restore] = withAsyncContext(() => nextTick())),

docs/introduction/interop.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import vueJsxVapor from 'vue-jsx-vapor/vite'
1515
export default defineConfig({
1616
plugins: [
1717
vueJsxVapor({
18-
macros: true,
1918
interop: true,
2019
}),
2120
],

docs/introduction/migration.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
## Migration from `vue-jsx`
44

5-
1. Don't support hyphenated prop name and hyphenated component name.
6-
2. `v-model` don't support Array Expression, use `v-model:$name$_trim={foo}` instead.
7-
3. Don't support `v-models` directive.
8-
4. Destructing props:
5+
1. Use `defineVaporComponent` instead of `defineComponent` to define Vapor components. The setup function of `defineVaporComponent` now returns a JSX expression directly—there is no need to return a function anymore.
6+
2. Don't support hyphenated prop name and hyphenated component name.
7+
3. `v-model` don't support Array Expression, use `v-model:$name$_trim={foo}` instead.
8+
4. Don't support `v-models` directive.
9+
5. Destructing props:
910

1011
> [!CAUTION]
1112
> ❌ The destructuring of props in a functional component will cause loss of reactivity.
@@ -36,7 +37,7 @@ export default () => {
3637
}
3738
```
3839

39-
2. ✅ Set the macros option to true, then use the `defineComponent` macro for wrapping.
40+
2. ✅ Set the macros option to true, then use the `defineVaporComponent` macro for wrapping.
4041

4142
- Setup
4243

docs/zh/features/macros.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,6 @@
22

33
为 JSX 设计的一系列宏。需要通过将 `macros` 设置为 `true` 来手动启用。
44

5-
|| Vue | Volar |
6-
| :---------------: | :----------------: | :----------------: |
7-
| `defineComponent` | :white_check_mark: | :white_check_mark: |
8-
| `defineModel` | :white_check_mark: | :white_check_mark: |
9-
| `defineSlots` | :white_check_mark: | :white_check_mark: |
10-
| `defineExpose` | :white_check_mark: | :white_check_mark: |
11-
| `defineStyle` | :white_check_mark: | :white_check_mark: |
12-
135
## 配置
146

157
::: code-group
@@ -65,7 +57,9 @@ export default {
6557

6658
:::
6759

68-
## defineComponent
60+
## defineComponent | defineVaporComponent
61+
62+
`defineComponent` 用于定义虚拟 DOM 组件,`defineVaporComponent` 用于定义 Vapor 组件
6963

7064
### 选项
7165

@@ -83,12 +77,12 @@ VueJsxVapor({
8377
```
8478

8579
- 支持 `await` 关键字。
86-
- 自动收集使用到的 props 到 `defineComponent``props` 选项中。
80+
- 自动收集使用到的 props 到 `defineVaporComponent``props` 选项中。
8781

8882
```tsx twoslash
89-
import { defineComponent, nextTick, Suspense, useAttrs } from 'vue'
83+
import { defineVaporComponent, nextTick, Suspense, useAttrs } from 'vue'
9084

91-
const Comp = defineComponent(
85+
const Comp = defineVaporComponent(
9286
async (props: {
9387
foo?: string
9488
bar?: string
@@ -114,8 +108,8 @@ export default () => (
114108
::: details 编译后代码
115109

116110
```tsx
117-
import { defineComponent, useAttrs, withAsyncContext } from 'vue'
118-
defineComponent(
111+
import { defineVaporComponent, useAttrs, withAsyncContext } from 'vue'
112+
defineVaporComponent(
119113
async (props) => {
120114
let __temp, __restore
121115
;([__temp, __restore] = withAsyncContext(() => nextTick())),

docs/zh/introduction/interop.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import vueJsxVapor from 'vue-jsx-vapor/vite'
1717
export default defineConfig({
1818
plugins: [
1919
vueJsxVapor({
20-
macros: true,
2120
interop: true,
2221
}),
2322
],

docs/zh/introduction/migration.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
## `vue-jsx` 迁移
44

5-
1. 不支持使用连字符的 prop 名称和组件名称。
6-
2. `v-model` 不支持数组表达式,请改用 `v-model:$name$_trim={foo}`
7-
3. 不支持 `v-models` 指令。
8-
4. 解构 props:
5+
1. 使用 `defineVaporComponent` 替代 `defineComponent` 来定义 Vapor 组件。`defineVaporComponent` 的 setup 函数现在可以直接返回 JSX 表达式,无需再返回一个函数。
6+
2. 不支持使用连字符的 prop 名称和组件名称。
7+
3. `v-model` 不支持数组表达式,请改用 `v-model:$name$_trim={foo}`
8+
4. 不支持 `v-models` 指令。
9+
5. 解构 props:
910

1011
> [!CAUTION]
1112
> ❌ 在函数式组件中解构 props 会导致响应性丢失。
@@ -36,7 +37,7 @@ export default () => {
3637
}
3738
```
3839

39-
2. ✅ 将 `macros` 选项设置为 `true`,然后使用 `defineComponent` 宏进行包装。
40+
2. ✅ 将 `macros` 选项设置为 `true`,然后使用 `defineVaporComponent` 宏进行包装。
4041

4142
- 配置
4243

@@ -119,9 +120,9 @@ const double = computed(() => foo * 2)
119120
console.log({ double: double.value }, [double.value])
120121
```
121122

122-
### defineComponent
123+
### defineVaporComponent
123124

124-
使用 `defineComponent` 宏来支持解构 props
125+
使用 `defineVaporComponent` 宏来支持解构 props
125126

126127
```tsx
127128
// 转换前

0 commit comments

Comments
 (0)