1- import { defineComponent , toRefs , watch , onUnmounted } from 'vue' ;
1+ import { defineComponent , toRefs , watch , onUnmounted , computed } from 'vue' ;
22import { tagProps , TagProps } from './tag-types' ;
33import { useClass , useColor } from './composables' ;
44import { 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