style: 优化代码
This commit is contained in:
parent
b20174d110
commit
26ac896f5c
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user