refactor(icon): reduce getter access (#9360)

* Update icon.vue

* Update icon.vue
This commit is contained in:
zhangenming 2022-08-30 21:23:13 +08:00 committed by GitHub
parent 954b8408af
commit d4d411c936
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,11 +19,12 @@ const props = defineProps(iconProps)
const ns = useNamespace('icon')
const style = computed<CSSProperties>(() => {
if (!props.size && !props.color) return {}
const { size, color } = props
if (!size && !color) return {}
return {
fontSize: isUndefined(props.size) ? undefined : addUnit(props.size),
'--color': props.color,
fontSize: isUndefined(size) ? undefined : addUnit(size),
'--color': color,
}
})
</script>