diff --git a/docs/.vitepress/locales/common.ts b/docs/.vitepress/locales/common.ts index 484267820..6ffe68e1b 100644 --- a/docs/.vitepress/locales/common.ts +++ b/docs/.vitepress/locales/common.ts @@ -165,6 +165,10 @@ export const sidebar = (lang: string): DefaultTheme.SidebarItem[] => { text: 'exportProps', link: `${urlPrefix}/features/export-props`, }, + { + text: 'exportExpose', + link: `${urlPrefix}/features/export-expose`, + }, ], }, ], diff --git a/docs/features/export-expose.md b/docs/features/export-expose.md new file mode 100644 index 000000000..8a7652fb4 --- /dev/null +++ b/docs/features/export-expose.md @@ -0,0 +1,174 @@ +# exportExpose + + + +Transform export statement as `defineExpose` params in Vue SFC `script-setup`. + +| Features | Supported | +| :----------: | :----------------: | +| Vue 3 | :white_check_mark: | +| Nuxt 3 | ? | +| Vue 2 | ? | +| Volar Plugin | :x: | + +## Usage + +Support these syntaxes: + +- local variable/function/class +- export with alias +- export from other file +- namespace export +- rename export + +### 1. local variable/function/class + +```vue + +``` + +::: details Compiled Code + +```vue + +``` + +::: + +### 2. export with alias + +```vue + +``` + +::: details Compiled Code + +```vue + +``` + +::: + +### 3. export from other file + +```vue + +``` + +::: details Compiled Code + +```vue + +``` + +::: + +### 4. namespace export + +```vue + +``` + +::: details Compiled Code + +```vue + +``` + +::: + +### 5. rename export + +```vue + +``` + +::: details Compiled Code + +```vue + +``` + +::: + + +## Limitations + +Currently does't support these following cases: + +```ts +// 1. export all ❌ +export * from '../types' + +// 2. export default ❌ +const a = 'a' +export default a +``` diff --git a/docs/zh-CN/features/export-expose.md b/docs/zh-CN/features/export-expose.md new file mode 100644 index 000000000..d957a2aba --- /dev/null +++ b/docs/zh-CN/features/export-expose.md @@ -0,0 +1,174 @@ +# exportExpose + + + +在 Vue SFC `script-setup` 中将 export 语句转换为 `defineExpose` 参数。 + +| 特性 | 支持 | +| :----------: | :----------------: | +| Vue 3 | :white_check_mark: | +| Nuxt 3 | ? | +| Vue 2 | ? | +| Volar Plugin | :x: | + +## 用法 + +支持以下语法: + +- 局部变量/函数/类 +- 别名导出 +- 从其他文件导出 +- 命名空间导出 +- 重命名导出 + +### 1. 局部变量/函数/类 + +```vue + +``` + +::: details 编译后代码 + +```vue + +``` + +::: + +### 2. 别名导出 + +```vue + +``` + +::: details 编译后代码 + +```vue + +``` + +::: + +### 3. 从其他文件导出 + +```vue + +``` + +::: details 编译后代码 + +```vue + +``` + +::: + +### 4. 命名空间导出 + +```vue + +``` + +::: details 编译后代码 + +```vue + +``` + +::: + +### 5. 重命名导出 + +```vue + +``` + +::: details 编译后代码 + +```vue + +``` + +::: + + +## 限制 + +当前不支持以下语法: + +```ts +// 1. 全部导出 ❌ +export * from '../types' + +// 2. 默认导出 ❌ +const a = 'a' +export default a +```