From cc1f21845a61ec4a12a2652a1a6b88868b56b5e9 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Wed, 15 Jul 2020 22:39:16 +0800 Subject: [PATCH] feat: update list --- components/list/Item.jsx | 16 +++++++--------- components/list/index.jsx | 14 ++++++-------- examples/App.vue | 2 +- examples/index.js | 6 ++++++ package.json | 2 +- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/components/list/Item.jsx b/components/list/Item.jsx index e252d442a..aa9c1b7f6 100644 --- a/components/list/Item.jsx +++ b/components/list/Item.jsx @@ -21,9 +21,8 @@ export const ListItemMetaProps = { title: PropTypes.any, }; -export const Meta = (props, { slots, attrs }) => { +export const AListItemMeta = (props, { slots }) => { const configProvider = inject('configProvider', ConfigConsumerProps); - const { style, class: _cls } = attrs; const getPrefixCls = configProvider.getPrefixCls; const { prefixCls: customizePrefixCls } = props; const prefixCls = getPrefixCls('list', customizePrefixCls); @@ -37,16 +36,15 @@ export const Meta = (props, { slots, attrs }) => { ); return ( -
+
{avatar &&
{avatar}
} {(title || description) && content}
); }; -Object.assign(Meta, { +Object.assign(AListItemMeta, { props: ListItemMetaProps, - inheritAttrs: false, __ANT_LIST_ITEM_META: true, }); @@ -57,7 +55,7 @@ function getGrid(grid, t) { export default { name: 'AListItem', inheritAttrs: false, - Meta, + Meta: AListItemMeta, props: ListItemProps, setup() { const listContext = inject('listContext', {}); @@ -91,7 +89,7 @@ export default { render() { const { grid, itemLayout } = this.listContext; const { prefixCls: customizePrefixCls, $slots, $attrs } = this; - const { class: _className } = $attrs; + const { class: _className, ...restAttrs } = $attrs; const getPrefixCls = this.configProvider.getPrefixCls; const prefixCls = getPrefixCls('list', customizePrefixCls); const extra = getComponent(this, 'extra'); @@ -107,11 +105,11 @@ export default { ))} ); - const children = $slots.default && $slots.default(); + const children = getSlot(this); const Tag = grid ? 'div' : 'li'; const itemChildren = (
diff --git a/examples/App.vue b/examples/App.vue index f079069e9..7043977a5 100644 --- a/examples/App.vue +++ b/examples/App.vue @@ -4,7 +4,7 @@