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

相关推荐
quo-te20 分钟前
AJAX简介
前端·ajax·okhttp
bingbingyihao31 分钟前
通过代码获取接口文档工具
开发语言·前端·javascript
月伤5931 分钟前
JS中Map对象与数组的相互转换
前端·javascript·html
SEO_juper2 小时前
解密 URL 参数:如何利用它们提升网站性能和用户体验
前端·javascript·ux·seo·url·数字营销·谷歌seo
nuIl2 小时前
让 Cursor 帮你把想法落地
前端·ai编程
HyaCinth2 小时前
Taro 数字滚动组件
javascript·react.js·taro
去伪存真2 小时前
看我如何破解api接口文档定义空白, 还不想手动写接口TS类型定义的困局
前端·typescript
skyWang4163 小时前
Vite模块联邦(vite-plugin-federation)实现去中心化微前端后台管理系统架构
前端
喝拿铁写前端3 小时前
你以为你是中级前端,其实你还停留在执行阶段-完整前端成长之路
前端
前端卧龙人3 小时前
uniapp开发技巧:开启代理与gzip优化实践
前端