【发布时间】:2023-03-15 15:00:02
【问题描述】:
我可以的
defineComponent({
props: {
name: { type: String as PropType<string> }
}
})
告诉 vue3 我的 props 类型是 { name: string },但是如果我有几个组件具有相同的 props 类型,我该如何共享定义?
如果我在 :
中定义道具const props = {
name: String as PropType<string>
}
然后像这样使用它:
defineComponent({
props: props,
})
不行,我在props的setup函数中得到的类型不对。
【问题讨论】: