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

相关推荐
ziqi5227 小时前
第二十五天笔记
前端·chrome·笔记
GISer_Jing7 小时前
Memory、Rules、Skills、MCP如何重塑AI编程
前端·人工智能·aigc·ai编程
xcs194057 小时前
前端 项目构建问题 \node_modules\loader-runner\lib\loadLoader.js
开发语言·前端·javascript
广然7 小时前
EVE-NG 镜像管理工具 1.1 Web 版本正式发布!
运维·服务器·前端
Data_Journal7 小时前
【无标题】
大数据·服务器·前端·数据库·人工智能
我爱加班、、7 小时前
new Map()+Array.from()整理elementPlus的级联器数据
linux·前端·javascript
Hx_Ma167 小时前
Map集合的5种遍历方式
java·前端·javascript
css趣多多7 小时前
render函数
前端·javascript·vue.js
web打印社区7 小时前
前端开发实现PDF打印需求:从基础方案到专业解决方案
前端·vue.js·react.js·electron·pdf
时光追逐者7 小时前
使用 MWGA 帮助 7 万行 Winforms 程序快速迁移到 WEB 前端
前端·c#·.net