Skip to content

Commit de81daf

Browse files
vaebekagol
authored andcommitted
fix(tag): 修复Tag标签primary类型选中状态下,关闭按钮颜色与背景色一致 (close DevCloudFE#1539)
1 parent 620d432 commit de81daf

File tree

1 file changed

+13
-7
lines changed
  • packages/devui-vue/devui/tag/src

1 file changed

+13
-7
lines changed

packages/devui-vue/devui/tag/src/tag.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineComponent, toRefs, watch, onUnmounted } from 'vue';
1+
import { defineComponent, toRefs, watch, onUnmounted, computed } from 'vue';
22
import { tagProps, TagProps } from './tag-types';
33
import { useClass, useColor } from './composables';
44
import { useNamespace } from '../../shared/hooks/use-namespace';
@@ -23,17 +23,23 @@ export default defineComponent({
2323
e.stopPropagation();
2424
emit('tagDelete', e);
2525
};
26+
27+
// 计算内容的颜色
28+
const contentColor = computed(() => {
29+
return isDefaultTag() ? '' : checked.value ? '#fff' : themeColor.value;
30+
});
31+
32+
// 关闭icon
2633
const closeIconEl = () => {
34+
const iconName = isDefaultTag() ? 'error-o' : 'close';
35+
2736
return deletable.value ? (
2837
<a class="remove-button" onClick={handleDelete}>
29-
{isDefaultTag() ? (
30-
<d-icon size="12px" name="error-o" color="#adb0b8" />
31-
) : (
32-
<d-icon size="12px" name="close" color={themeColor.value} />
33-
)}
38+
<d-icon size="12px" name={iconName} color={contentColor.value} />
3439
</a>
3540
) : null;
3641
};
42+
3743
const unWatch = watch(checked, (newVal) => {
3844
emit('checkedChange', newVal);
3945
});
@@ -45,7 +51,7 @@ export default defineComponent({
4551
class={tagClass.value}
4652
style={{
4753
display: 'block',
48-
color: checked.value ? '#fff' : themeColor.value,
54+
color: contentColor.value,
4955
backgroundColor: checked.value ? themeColor.value : !color.value ? '' : 'var(--devui-base-bg, #ffffff)',
5056
}}
5157
title={tagTitle}>

0 commit comments

Comments
 (0)