From c4d3b3efff848abd8ef0c4f33d7a627d15f704f9 Mon Sep 17 00:00:00 2001 From: xingyu Date: Thu, 11 May 2023 10:24:14 +0800 Subject: [PATCH] fix: dict tag --- src/components/DictTag/src/DictTag.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/DictTag/src/DictTag.vue b/src/components/DictTag/src/DictTag.vue index 23c3e5a3..ed535d92 100644 --- a/src/components/DictTag/src/DictTag.vue +++ b/src/components/DictTag/src/DictTag.vue @@ -27,6 +27,9 @@ export default defineComponent({ } else { dictOptions = getDictOptions(dictType) } + if (dictOptions && dictOptions.length === 0) { + return + } dictOptions.forEach((dict: DictDataType) => { if (dict.value === value) { if (dict.colorType + '' === 'primary') { @@ -49,6 +52,10 @@ export default defineComponent({ return null } getDictObj(props.type, props.value.toString()) + + if (dictData.value === undefined) { + return null + } // 添加标签的文字颜色为白色,解决自定义背景颜色时标签文字看不清的问题 && isHexColor(dictData.value?.cssClass) return ( - {dictData.value?.label} + {dictData.value?.label || ''} ) }