阿里图标库引入

This commit is contained in:
冯辉
2025-10-20 16:15:29 +08:00
parent d9c1f83693
commit 968e6b4091
29 changed files with 3718 additions and 70 deletions

View File

@@ -0,0 +1,70 @@
<template>
<text class="iconfont" :class="iconClass" :style="iconStyle" @click="handleClick"></text>
</template>
<script setup>
import { computed } from 'vue'
const props = defineProps({
// 图标名称home、user、search
name: {
type: String,
required: true
},
// 图标大小单位rpx
size: {
type: [String, Number],
default: 32
},
// 图标颜色
color: {
type: String,
default: ''
},
// 是否粗体
bold: {
type: Boolean,
default: false
}
})
const emit = defineEmits(['click'])
// 图标类名
const iconClass = computed(() => {
const prefix = props.name.startsWith('icon-') ? '' : 'icon-'
return `${prefix}${props.name}`
})
// 图标样式
const iconStyle = computed(() => {
const style = {
fontSize: `${props.size}rpx`
}
if (props.color) {
style.color = props.color
}
if (props.bold) {
style.fontWeight = 'bold'
}
return style
})
// 点击事件
const handleClick = (e) => {
emit('click', e)
}
</script>
<style scoped>
.iconfont {
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
display: inline-block;
}
</style>