fix(components): [ElFormItem] label will be show undefined (#4487)

This commit is contained in:
C.Y.Kun 2021-11-23 00:17:19 +08:00 committed by GitHub
parent 0832a55f89
commit 8fe4f1e65e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,8 +10,8 @@
class="el-form-item__label" class="el-form-item__label"
:style="labelStyle" :style="labelStyle"
> >
<slot name="label" :label="label + elForm.labelSuffix"> <slot name="label" :label="currentLabel">
{{ label + elForm.labelSuffix }} {{ currentLabel }}
</slot> </slot>
</label> </label>
</LabelWrap> </LabelWrap>
@ -345,6 +345,10 @@ export default defineComponent({
) )
}) })
const currentLabel = computed(
() => (props.label || '') + (elForm.labelSuffix || '')
)
return { return {
formItemRef, formItemRef,
formItemClass, formItemClass,
@ -356,6 +360,7 @@ export default defineComponent({
labelFor, labelFor,
resetField, resetField,
clearValidate, clearValidate,
currentLabel,
} }
}, },
}) })