数据结构优化
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
:is="iconComponent"
|
||||
:class="className"
|
||||
:style="style"
|
||||
:size="size"
|
||||
:size="iconSize"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -35,4 +35,13 @@ const iconComponent = computed(() => {
|
||||
const iconName = toPascalCase(props.name) as keyof typeof LucideIcons
|
||||
return LucideIcons[iconName] || LucideIcons.AlertCircle
|
||||
})
|
||||
|
||||
// 确保 size 是 number 类型
|
||||
const iconSize = computed(() => {
|
||||
if (typeof props.size === 'string') {
|
||||
const parsed = parseInt(props.size, 10)
|
||||
return isNaN(parsed) ? 24 : parsed
|
||||
}
|
||||
return props.size ?? 24
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user