From 4d58dbe3a665fc82510d5d7cb34a83b152565824 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Mon, 17 Aug 2020 19:57:35 +0800 Subject: [PATCH] fix(Field): should not render empty label --- src/cell/index.js | 5 +++-- src/field/index.js | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/cell/index.js b/src/cell/index.js index 8a7afee58..dba2ff074 100644 --- a/src/cell/index.js +++ b/src/cell/index.js @@ -19,7 +19,8 @@ export default createComponent({ setup(props, { slots, emit }) { return function () { const { icon, size, title, label, value, isLink } = props; - const showTitle = slots.title || isDef(title); + const titleSlot = slots.title?.(); + const showTitle = titleSlot || isDef(title); function Label() { const showLabel = slots.label || isDef(label); @@ -40,7 +41,7 @@ export default createComponent({ class={[bem('title'), props.titleClass]} style={props.titleStyle} > - {slots.title ? slots.title() : {title}} + {slots.title ? titleSlot : {title}} {Label()} ); diff --git a/src/field/index.js b/src/field/index.js index b1144669e..8d02b8fd0 100644 --- a/src/field/index.js +++ b/src/field/index.js @@ -557,12 +557,14 @@ export default createComponent({ render() { const slots = this.$slots; const labelAlign = this.getProp('labelAlign'); + const Label = this.genLabel(); + const LeftIcon = this.genLeftIcon(); return ( LeftIcon : null, + title: Label ? () => Label : null, extra: slots.extra, }} icon={this.leftIcon}