<template>
    <el-icon v-if="isComponent">
        <component :is="icon"></component>
    </el-icon>
    <i :class="['g-icon', icon]" v-else></i>
</template>

<script lang="ts" setup>
import { resolveDynamicComponent, computed } from 'vue'

const props = defineProps({
    icon: String,
})

const isComponent = computed(() => props.icon && typeof resolveDynamicComponent(props.icon) !== 'string')
</script>