如何在 defineComponent 中定义 slot 的泛型? #8816
Unanswered
sixdjango
asked this question in
Help/Questions
Replies: 4 comments 5 replies
-
i know how to write template generic <script setup lang="tsx" generic="T extends string | number, U extends {a:string}">
defineProps<{
id: T
list: U[]
}>()
defineSlots<{
default: (props: { item: U }) => VNode
}>()
</script>
|
Beta Was this translation helpful? Give feedback.
2 replies
-
所以我想知道 defineComponent 里如何实现 slot 泛型 像 template 里一样 |
Beta Was this translation helpful? Give feedback.
0 replies
-
找到解决办法了么,我也遇到了,书写的时候没有类型提示 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Vue version
3.34
Link to minimal reproduction
https://stackblitz.com/edit/vitejs-vite-gpqdjq?file=src%2Fcomponents%2FTsxGenericSlot.tsx
Steps to reproduce
如何在 tsx 中把泛型传递给 slot 的定义中呢?按照官方教程也只能是在 function component 中定义 泛型。作用域无法到达 slots option 这里所以应该怎么写才能在 defineComponents 中对 slots type 进行泛型
What is expected?
What is actually happening?
无法实现 defineComponent 中对 slots 的泛型支持
System Info
No response
Any additional comments?
No response
Beta Was this translation helpful? Give feedback.
All reactions