// 从 '@/components/SvgIcon/index.vue' 导入 SvgIcon 组件 import SvgIcon from '@/components/SvgIcon/index.vue' // 从 'vue' 导入 h 函数和 defineComponent 函数 import { h, defineComponent } from 'vue' // 定义一个名为 useRenderIcon 的函数,它接受两个参数:iconName(字符串类型)和 attrs(可选的任意类型) export function useRenderIcon(iconName: string, attrs?: any) { // 使用 defineComponent 函数定义一个新的组件 return defineComponent({ // 新组件的名称为 'SvgIcon' name: 'SvgIcon', // 定义组件的渲染函数 render() { // 使用 h 函数创建一个 SvgIcon 组件的虚拟节点 // 第一个参数是要创建的组件(这里是 SvgIcon) // 第二个参数是一个对象,包含要传递给 SvgIcon 组件的属性 // 'icon' 属性的值是传入的 iconName // '...attrs' 表示将 attrs 对象中的所有属性也传递给 SvgIcon 组件 return h(SvgIcon, { icon: iconName, ...attrs }) } }) }