Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

createComponent 的定义

image.png

使用在这里

image.png

image.png

问题如下

按照现在的写法,这里的高阶函数 createComponent 没有接受到外部传入的泛型,将使用默认的泛型DefaultProps等,这里如何使得<Props = DefaultProps...>等类型信息可以从外部传入?

比如:

传入 Props: { name: string },让createComponent接收到的 Props 类型就是我这里传入的。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

那三个泛型是你在用createComponent返回的函数时用的

const component = createComponent('xxx');
component<SomeProps,SomeEvents,SomeSlots>(...)

而且你这也不叫高阶函数


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...