element-plus Icon 图标全局使用方法,可供菜单图标使用
封装组件<template><el-icon :size="size" :color="color"><component :is="icon"></component></el-icon></template><script>import { ref, defineComponent } from "vue";i
·
封装组件
<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" />
更多推荐
已为社区贡献1条内容
所有评论(0)