Skip to content

exportProps

稳定性: 实验性 ⚠️ 实验性功能,风险自负

在 Vue 中使用 Svelte 风格声明 props

特性支持
Vue 3
Nuxt 3?
Vue 2
Volar Plugin

用法

使用导出语法来声明 props

vue
<script setup lang="ts">
export let foo: string
export const bar: number = 1 // 带有默认值
</script>

Volar 配置

jsonc
// tsconfig.json
{
  "vueCompilerOptions": {
    "target": 3,
    "plugins": [
      "@vue-macros/volar/export-props",
      // ...更多功能
    ],
  },
}