mirror of
https://github.com/fugary/simple-element-plus-template.git
synced 2025-12-09 20:37:48 +00:00
图标工具
This commit is contained in:
@@ -1,19 +1,29 @@
|
||||
<script setup>
|
||||
defineProps({
|
||||
import { computed } from 'vue'
|
||||
import { ICON_PREFIX } from '@/icons'
|
||||
import kebabCase from 'lodash/kebabCase'
|
||||
|
||||
const props = defineProps({
|
||||
icon: {
|
||||
type: String,
|
||||
required: false
|
||||
}
|
||||
})
|
||||
const calcIcon = computed(() => {
|
||||
if (props.icon) {
|
||||
return `${ICON_PREFIX}${kebabCase(props.icon)}`
|
||||
}
|
||||
return props.icon
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-icon
|
||||
v-if="icon"
|
||||
v-if="calcIcon"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
<component
|
||||
:is="icon"
|
||||
:is="calcIcon"
|
||||
/>
|
||||
</el-icon>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user