@@ -21,43 +21,35 @@ export const VPIcon = defineComponent({
21
21
/**
22
22
* Icon prefix
23
23
*/
24
- prefix : {
25
- type : String ,
26
- default : '' ,
27
- } ,
24
+ prefix : String ,
28
25
29
26
/**
30
27
* Icon class
31
28
*
32
29
* 图标类名
33
30
*/
34
- icon : { type : String , default : '' } ,
31
+ icon : String ,
32
+
35
33
/**
36
34
* Icon color
37
35
*
38
36
* 图标颜色
39
37
*/
40
- color : { type : String , default : '' } ,
38
+ color : String ,
41
39
42
40
/**
43
41
* Icon size
44
42
*
45
43
* 图标大小
46
44
*/
47
- size : {
48
- type : [ String , Number ] ,
49
- default : '' ,
50
- } ,
45
+ size : [ String , Number ] ,
51
46
52
47
/**
53
48
* Icon vertical align
54
49
*
55
50
* 图标垂直对齐方式
56
51
*/
57
- verticalAlign : {
58
- type : String ,
59
- default : '' ,
60
- } ,
52
+ verticalAlign : String ,
61
53
62
54
/**
63
55
* Icon sizing
@@ -74,18 +66,21 @@ export const VPIcon = defineComponent({
74
66
75
67
setup ( props ) {
76
68
const imageLink = computed ( ( ) =>
77
- isLinkHttp ( props . icon )
78
- ? props . icon
79
- : isLinkAbsolute ( props . icon )
80
- ? withBase ( props . icon )
81
- : null ,
69
+ props . icon
70
+ ? isLinkHttp ( props . icon )
71
+ ? props . icon
72
+ : isLinkAbsolute ( props . icon )
73
+ ? withBase ( props . icon )
74
+ : null
75
+ : null ,
82
76
)
83
77
84
78
const attrs = computed ( ( ) => {
85
79
const attrsObject : Record < string , unknown > = { }
86
80
const styleObject : CSSProperties = { }
87
81
const { type, verticalAlign, size, sizing } = props
88
82
83
+ if ( props . color ) styleObject . color = props . color
89
84
if ( size )
90
85
styleObject [ '--icon-size' ] = Number . isNaN ( Number ( size ) )
91
86
? ( size as string )
@@ -107,7 +102,7 @@ export const VPIcon = defineComponent({
107
102
icon . includes ( 'fa-' ) || / ^ f a .$ / . test ( icon ) ? icon : `fa-${ icon } `
108
103
109
104
return ( ) : VNode | null => {
110
- const { type, icon, prefix, sizing } = props
105
+ const { type, icon, prefix = '' , sizing } = props
111
106
112
107
if ( ! icon ) return null
113
108
0 commit comments