mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 02:16:12 +08:00
fix(Field): should not render empty label
This commit is contained in:
parent
832ed6f80f
commit
4d58dbe3a6
@ -19,7 +19,8 @@ export default createComponent({
|
|||||||
setup(props, { slots, emit }) {
|
setup(props, { slots, emit }) {
|
||||||
return function () {
|
return function () {
|
||||||
const { icon, size, title, label, value, isLink } = props;
|
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() {
|
function Label() {
|
||||||
const showLabel = slots.label || isDef(label);
|
const showLabel = slots.label || isDef(label);
|
||||||
@ -40,7 +41,7 @@ export default createComponent({
|
|||||||
class={[bem('title'), props.titleClass]}
|
class={[bem('title'), props.titleClass]}
|
||||||
style={props.titleStyle}
|
style={props.titleStyle}
|
||||||
>
|
>
|
||||||
{slots.title ? slots.title() : <span>{title}</span>}
|
{slots.title ? titleSlot : <span>{title}</span>}
|
||||||
{Label()}
|
{Label()}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -557,12 +557,14 @@ export default createComponent({
|
|||||||
render() {
|
render() {
|
||||||
const slots = this.$slots;
|
const slots = this.$slots;
|
||||||
const labelAlign = this.getProp('labelAlign');
|
const labelAlign = this.getProp('labelAlign');
|
||||||
|
const Label = this.genLabel();
|
||||||
|
const LeftIcon = this.genLeftIcon();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Cell
|
<Cell
|
||||||
v-slots={{
|
v-slots={{
|
||||||
icon: this.genLeftIcon,
|
icon: LeftIcon ? () => LeftIcon : null,
|
||||||
title: this.genLabel,
|
title: Label ? () => Label : null,
|
||||||
extra: slots.extra,
|
extra: slots.extra,
|
||||||
}}
|
}}
|
||||||
icon={this.leftIcon}
|
icon={this.leftIcon}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user