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代码。

相关推荐
狗头大军之江苏分军6 小时前
《潮水漫过十七岁》倒计时
前端·javascript·后端
小码哥0687 小时前
租房平台源码部署验收:房源样例、区域字典与看房预约逐项验证
前端·javascript·vue.js·租房小程序·租房系统·租房软件
htzyl2067 小时前
JS原型链与继承:class 底下到底是什么
前端·javascript·ecmascript 6
一条Go7 小时前
15 套品牌色 + 双模式:把颜色关进三层 token
前端·github
htzyl2068 小时前
JS-关于闭包捕获与释放
前端·javascript
狗头大军之江苏分军8 小时前
《潮水漫过十七岁》好久没写了
前端·javascript·后端
console.log('npc')8 小时前
Python第9课 类学习笔记,前端js语法对照
前端·python·学习
橙序员小站8 小时前
没有AI,我根本不知道同事有多苦
前端·微信小程序
ssshooter10 小时前
Replit 项目本地跑:一份实测过的改造清单
前端·后端·设计模式
濮水大叔10 小时前
Cabloy/Zova 与 Next.js 的布局组件差异:从目录嵌套到路由应用壳
前端·typescript·next.js