Closed guaijie closed 1 month ago
缺乏泛型支持的组件失去了类型推断的能力:
import { Select } from 'ant-design-vue' const model = reactive({ sex: 1 }) const sexRef = ref<number>() <Select options={options} v-model:value={model.sex} onChange={(v) => sexRef.value = v} /> // model.sex 是一个 number 类型,onChange 事件中可以推断出 v 应该是个 number 类型,而非内置的 SelectValue 类型,这将使得 sexRef.value 赋值报错。因此项目中会存在大量的类型转换问题
有关‘数据录入’和 ‘数据展示’的组件都应该支持泛型
type SelectProps<T> = { value?: T, //... } // 使用 defineComponent defineComponent(<T,>(props: SelectProps<T>) => { }, { name: 'ASelect', props: getSelectProps() })
// setup <script setup lang="tsx" generic="T extends object"> const props = defineProps<SelectProps<T>>() </script>
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days
What problem does this feature solve?
缺乏泛型支持的组件失去了类型推断的能力:
What does the proposed API look like?
有关‘数据录入’和 ‘数据展示’的组件都应该支持泛型