mirror of
https://gitee.com/ant-design-vue/ant-design-vue.git
synced 2024-12-05 05:29:01 +08:00
a2f7d6d062
closes vueComponent/ant-design-vue#5765 Add `compatConfig: { MODE: 3 }` to all component definitions to signal to `@vue/compat` not to use any Vue 2 compatibility features.
46 lines
1.5 KiB
Vue
46 lines
1.5 KiB
Vue
import type { ExtractPropTypes } from 'vue';
|
|
import { defineComponent } from 'vue';
|
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
|
import PropTypes from '../_util/vue-types';
|
|
|
|
export const listItemMetaProps = () => ({
|
|
avatar: PropTypes.any,
|
|
description: PropTypes.any,
|
|
prefixCls: String,
|
|
title: PropTypes.any,
|
|
});
|
|
|
|
export type ListItemMetaProps = Partial<ExtractPropTypes<ReturnType<typeof listItemMetaProps>>>;
|
|
|
|
export default defineComponent({
|
|
compatConfig: { MODE: 3 },
|
|
name: 'AListItemMeta',
|
|
props: listItemMetaProps(),
|
|
displayName: 'AListItemMeta', // 兼容历史函数式组件
|
|
__ANT_LIST_ITEM_META: true,
|
|
slots: ['avatar', 'description', 'title'],
|
|
setup(props, { slots }) {
|
|
const { prefixCls } = useConfigInject('list', props);
|
|
return () => {
|
|
const classString = `${prefixCls.value}-item-meta`;
|
|
const title = props.title ?? slots.title?.();
|
|
const description = props.description ?? slots.description?.();
|
|
const avatar = props.avatar ?? slots.avatar?.();
|
|
const content = (
|
|
<div class={`${prefixCls.value}-item-meta-content`}>
|
|
{title && <h4 class={`${prefixCls.value}-item-meta-title`}>{title}</h4>}
|
|
{description && (
|
|
<div class={`${prefixCls.value}-item-meta-description`}>{description}</div>
|
|
)}
|
|
</div>
|
|
);
|
|
return (
|
|
<div class={classString}>
|
|
{avatar && <div class={`${prefixCls.value}-item-meta-avatar`}>{avatar}</div>}
|
|
{(title || description) && content}
|
|
</div>
|
|
);
|
|
};
|
|
},
|
|
});
|