From 3f9a77a8095816890bcbf9ab796fefd2e6ca4821 Mon Sep 17 00:00:00 2001 From: huangchen1031 Date: Sat, 31 Aug 2024 22:48:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(card):=20loading=E5=B1=9E=E6=80=A7=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0TNode=E6=94=AF=E6=8C=81=20(#3051)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(card): loading属性增加TNode支持 fix #2997 * fix(card): 在不使用loading属性的时候,去掉loading parent --- src/card/Card.tsx | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/card/Card.tsx b/src/card/Card.tsx index 1f34ed579e..dee578d108 100644 --- a/src/card/Card.tsx +++ b/src/card/Card.tsx @@ -133,20 +133,31 @@ const Card = forwardRef((props, ref) => { ); const card = ( -
+ <> {showHeader ? renderHeader() : null} {renderCover} {renderChildren} {renderFooter} -
+ ); - return loading ? ( - - {card} - - ) : ( - React.cloneElement(card, { style }) + let childrenNode: React.ReactNode = null; + if (!Reflect.has(props, 'loading')) { + childrenNode = React.cloneElement(card, { style }); + } else if (React.isValidElement(loading)) { + childrenNode = React.cloneElement(loading, null, card); + } else { + childrenNode = ( + + {card} + + ); + } + + return ( +
+ {childrenNode} +
); });