Existing Component
Yes
Component Name
All components
Description
I'm encapsulating ElButton
to VButton
, instead of manually adding prop types, it'll be much more convenient to use the original IButtonProps
instead, however, it's not exported:
import { ElButton } from 'element-plus'
import { defineComponent, ref } from 'vue'
export default defineComponent({
inheritAttrs: false,
// 👇 manually adding prop types
setup(props: { type: string; size: string }, { attrs, slots }) {
// 👇 it'll be much more convenient to use `IButtonProps` instead
// setup(props: IButtonProps, { attrs, slots }) {
const btn = ref<InstanceType<typeof ElButton>>()
return () => (
<ElButton
class='v-button'
ref={btn}
size='medium'
onClick={() => btn.value?.$el.blur()}
{...attrs}
vSlots={slots}
/>
)
},
})
This request applies to all available components.
I'm relatively new to typescript, please correct me if it's infeasible. Also, if there's a better way for achieving the same typing experience without doing the exports, please let me know.
5条答案
按热度按时间kfgdxczn1#
Yeah, I agree with you, this is something that we really need, but we are kind of in the situation of lack of people who can implement this. If you are willing to do this, that'd be great, but if you don't we will queue this task into our backlog in order that we can solve it when we got time.
lx0bsm1f2#
@JeremyWuuuuu Please queue it first.
7rtdyuoh3#
Yeah, I agree with you, this is something that we really need, but we are kind of in the situation of lack of people who can implement this. If you are willing to do this, that'd be great, but if you don't we will queue this task into our backlog in order that we can solve it when we got time.
@JeremyWuuuuu
我也碰到了同样的问题。
最近在做vue2的迁移,之前vue2的一些组件大量使用mixin和解构props来复用element-ui的method、event和props
单纯的提供props的interface还不够
可能需要每个组件再提供一个hook用来复用method和event等
或许是一个很大的迭代
wi3ka0sx4#
We are working on it. There will be news to notify you.
1zmg4dgp5#
We have exported the props, emits, and types of some components.