element-plus el-button 自定义添加icon的方法

前言


不知道为什么设置一个icon,要这么麻烦。

我使用的是"@element-plus/icons-vue": "^2.1.0", "element-plus": "^2.4.2"

代码


复制代码
      <el-button type="primary">
        <el-icon>
          <IcGraph />	// 这里是一个组件,由import IcGraph from '@/assets/images/ic_graph.vue'导入
        </el-icon>
        <span style="vertical-align: middle"> Search </span>
      </el-button>

其中的ic_graph.vue的代码:

复制代码
<template>
  <svg width="32.000000" height="32.000000" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <desc>
        Created with Pixso.
    </desc>
    <defs>
      <clipPath id="clip17_595">
        <rect id="数据图" width="32.000000" height="32.000000" fill="white"/>
      </clipPath>
    </defs>
    <g clip-path="url(#clip17_595)">
      <path id="path" d="M16 28.6667L16 17.3333C16 16.5969 16.5969 16 17.3333 16L28.6667 16C28.6667 9.00439 22.9956 3.33331 16 3.33331C9.00441 3.33331 3.33334 9.00439 3.33334 16C3.33334 22.9956 9.00441 28.6667 16 28.6667Z" stroke="#808080" stroke-width="1.500000" stroke-linejoin="round"/>
      <rect id="rect" x="20.000000" y="20.000000" width="8.000000" height="8.000000" stroke="#808080" stroke-width="1.500000" stroke-linejoin="round"/>
    </g>
  </svg>
</template>

其实就是<template>里面,添加从设计稿复制的svg代码。

相关推荐
武昌库里写JAVA1 小时前
C语言 #pragma once - C语言零基础入门教程
vue.js·spring boot·sql·layui·课程设计
iCoding911 小时前
前端分页 vs 后端分页:技术选型
前端·后端·系统架构
mingtianyihou331 小时前
使用 Service Worker 限制请求并发数
前端
张可爱1 小时前
20251017-Vue2八股文整理(上篇)
前端
FanetheDivine1 小时前
ts中如何描述一个复杂函数的类型
前端·typescript
lightgis2 小时前
chrome中的axure插件提示无法不受支持
前端·chrome
速易达网络2 小时前
Vue3 原生移动应用开发来了
前端·javascript·css
渣哥2 小时前
别再乱用了!Spring AOP 与 AspectJ 的区别比你想的复杂
javascript·后端·面试
GISer_Jing2 小时前
LLM对话框项目技术栈&重难点总结
前端·ai·node.js
患得患失9492 小时前
【Turborepo】【Next】 Turborepo + Next.js 前后端精简搭建笔记(带官网)
开发语言·javascript·笔记