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": ["vue-macros/volar"],
},
}
Kevin Deng
zhiyuanzmj
Leo