From a03aa6e597439abb4dcfc319a0072f455b091ccd Mon Sep 17 00:00:00 2001 From: i18u Date: Wed, 9 Dec 2020 16:40:02 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20label=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=A3=B0=E6=98=8E=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/form/ItemLabel.tsx | 7 +++-- .../src/components/form/interface.ts | 26 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/packages/components/src/components/form/ItemLabel.tsx b/packages/components/src/components/form/ItemLabel.tsx index 24e617fe3d..3970a6933d 100644 --- a/packages/components/src/components/form/ItemLabel.tsx +++ b/packages/components/src/components/form/ItemLabel.tsx @@ -4,7 +4,8 @@ import classNames from 'classnames'; import { FormLabelAlign, RequiredMark } from './context'; export interface Props { - label?: string; + label?: React.ReactNode; + title?: string; fieldId?: string; prefixCls: string; labelWidth?: number; @@ -21,6 +22,7 @@ const ItemLabel: React.FC = (props: Props) => { const { prefixCls, label, + title, labelWidth, fieldId, afterLabel, @@ -35,6 +37,7 @@ const ItemLabel: React.FC = (props: Props) => { const isOptional = !required && requiredMark === 'optional'; const innerMarker = isOptional ? '(选填)' : '*'; const mergedRequiredMarker = marker !== undefined ? marker : innerMarker; + const mergedTitle = title ?? typeof label === 'string' ? (label as string) : '' const cls = classNames( `${prefixCls}-label`, isRequired && `${prefixCls}-label-required`, @@ -61,7 +64,7 @@ const ItemLabel: React.FC = (props: Props) => { return (
{label && ( -