style: 优化代码

This commit is contained in:
dap 2024-10-11 08:08:19 +08:00
parent b20174d110
commit 26ac896f5c

View File

@ -41,11 +41,14 @@ const label = computed<number | string>(() => {
const current = props.dicts.find((item) => item.dictValue == props.value); const current = props.dicts.find((item) => item.dictValue == props.value);
return current?.dictLabel ?? 'unknown'; return current?.dictLabel ?? 'unknown';
}); });
const tagComponent = computed(() => (color.value ? Tag : 'div'));
</script> </script>
<template> <template>
<div> <div>
<Tag v-if="color" :class="cssClass" :color="color">{{ label }}</Tag> <component :is="tagComponent" :class="cssClass" :color="color">
<div v-if="!color" :class="cssClass">{{ label }}</div> {{ label }}
</component>
</div> </div>
</template> </template>