Skip to content

Commit 1da0e31

Browse files
committedJan 16, 2025
fix(plugin-icon): fix color prop not working
1 parent b66125e commit 1da0e31

File tree

1 file changed

+15
-20
lines changed
  • plugins/features/plugin-icon/src/client/components

1 file changed

+15
-20
lines changed
 

‎plugins/features/plugin-icon/src/client/components/VPIcon.ts

+15-20
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,35 @@ export const VPIcon = defineComponent({
2121
/**
2222
* Icon prefix
2323
*/
24-
prefix: {
25-
type: String,
26-
default: '',
27-
},
24+
prefix: String,
2825

2926
/**
3027
* Icon class
3128
*
3229
* 图标类名
3330
*/
34-
icon: { type: String, default: '' },
31+
icon: String,
32+
3533
/**
3634
* Icon color
3735
*
3836
* 图标颜色
3937
*/
40-
color: { type: String, default: '' },
38+
color: String,
4139

4240
/**
4341
* Icon size
4442
*
4543
* 图标大小
4644
*/
47-
size: {
48-
type: [String, Number],
49-
default: '',
50-
},
45+
size: [String, Number],
5146

5247
/**
5348
* Icon vertical align
5449
*
5550
* 图标垂直对齐方式
5651
*/
57-
verticalAlign: {
58-
type: String,
59-
default: '',
60-
},
52+
verticalAlign: String,
6153

6254
/**
6355
* Icon sizing
@@ -74,18 +66,21 @@ export const VPIcon = defineComponent({
7466

7567
setup(props) {
7668
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,
8276
)
8377

8478
const attrs = computed(() => {
8579
const attrsObject: Record<string, unknown> = {}
8680
const styleObject: CSSProperties = {}
8781
const { type, verticalAlign, size, sizing } = props
8882

83+
if (props.color) styleObject.color = props.color
8984
if (size)
9085
styleObject['--icon-size'] = Number.isNaN(Number(size))
9186
? (size as string)
@@ -107,7 +102,7 @@ export const VPIcon = defineComponent({
107102
icon.includes('fa-') || /^fa.$/.test(icon) ? icon : `fa-${icon}`
108103

109104
return (): VNode | null => {
110-
const { type, icon, prefix, sizing } = props
105+
const { type, icon, prefix = '', sizing } = props
111106

112107
if (!icon) return null
113108

0 commit comments

Comments
 (0)
Please sign in to comment.