templateRef
稳定性:
实验性
⚠️ 实验性功能,风险自负使用 DefineGeneric
逐个声明单个范型。
对于
setup-sfc
特别有用。
Features | Supported |
---|---|
Volar Plugin | ✅ |
Basic Usage
vue
<script setup lang="ts">
defineOptions({
name: 'App',
})
type T = DefineGeneric<number>
defineProps<{
foo: T
}>()
</script>
<template>
<App foo="1" /></template>
Volar 配置
jsonc
// tsconfig.json
{
"vueCompilerOptions": {
"plugins": [
"@vue-macros/volar/define-generic",
// ...more feature
],
},
}