封装组件

<template>
  <el-icon :size="size" :color="color">
    <component :is="name"></component>
  </el-icon>
</template>

<script>
import { ref, defineComponent } from "vue";
import * as Icons from "@element-plus/icons";

export default defineComponent({
  components: Icons,
  name: "ElIcons",
  props: {
    name: {
      type: String,
      required: true,
    },
    size: {
      type: String,
      default: "",
    },
    color: {
      type: String,
      default: "",
    },
  },
});
</script>

调用方法

<el-icons :name="item.meta.icon"  />
Logo

前往低代码交流专区

更多推荐