defineGeneric
稳定性:
稳定
使用 DefineGeneric
逐个声明单个范型。
对于
setup-sfc
特别有用。
Features | Supported |
---|---|
Volar Plugin | ✅ |
基本用法
vue
<script setup lang="ts"> defineOptions({ name: 'App', }) type T = DefineGeneric<number> defineProps<{ foo: T }>() </script> <template> <App foo="1" /></template>
Volar 配置
jsonc
{ "vueCompilerOptions": { "plugins": ["unplugin-vue-macros/volar"], }, }