From d6c11fa9012e96eae2bdaefb049c462684cb740f Mon Sep 17 00:00:00 2001 From: chenshuai2144 Date: Mon, 2 Nov 2020 13:43:03 +0800 Subject: [PATCH] less code --- components/page-header/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/page-header/index.tsx b/components/page-header/index.tsx index 51ad3c8e7b..7c754562eb 100644 --- a/components/page-header/index.tsx +++ b/components/page-header/index.tsx @@ -69,13 +69,14 @@ const getBackIcon = (props: PageHeaderProps, direction: string = 'ltr') => { const renderTitle = (prefixCls: string, props: PageHeaderProps, direction: string = 'ltr') => { const { title, avatar, subTitle, tags, extra, onBack } = props; const headingPrefixCls = `${prefixCls}-heading`; - // 如果 什么都没有,直接返回一个 空 - if (!title && !subTitle && !tags && !extra) { + const hasHeading = title || subTitle || tags || extra; + // 如果 什么都没有,直接返回一个 null + if (!hasHeading) { return null; } const backIcon = getBackIcon(props, direction); const backIconDom = renderBack(prefixCls, backIcon, onBack); - const hasTitle = backIconDom || avatar || title || subTitle || tags || extra; + const hasTitle = backIconDom || avatar || hasHeading; return (
{hasTitle && (