ant-design-vue/components/vc-virtual-list/Item.tsx

25 lines
549 B
Vue
Raw Normal View History

2021-06-26 01:35:40 +00:00
import type { FunctionalComponent, PropType } from 'vue';
import { cloneVNode } from 'vue';
2020-10-01 09:20:10 +00:00
export interface ItemProps {
setRef: (element: HTMLElement) => void;
}
const Item: FunctionalComponent<ItemProps> = ({ setRef }, { slots }) => {
const children = slots.default?.();
return children && children.length
? cloneVNode(children[0], {
2020-10-17 04:14:13 +00:00
ref: setRef as any,
2020-10-01 09:20:10 +00:00
})
: children;
};
2020-10-07 14:49:01 +00:00
Item.props = {
setRef: {
type: Function as PropType<(element: HTMLElement) => void>,
default: () => {},
},
};
2020-10-17 04:14:13 +00:00
2020-10-01 09:20:10 +00:00
export default Item;