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

相关推荐
答案answer8 分钟前
一些经典的3D编辑器开源项目
前端·开源·three.js
亿元程序员24 分钟前
Creator都快4.0了,怎么能没有这样的功能?
前端
q***649726 分钟前
SpringMVC 请求参数接收
前端·javascript·算法
万少30 分钟前
流碧卡片 6 小时闪电开发 AI gemini-3-pro-preview ! 秒出小红书爆款图,免下载直接用
前端·后端·ai编程
悟能不能悟31 分钟前
<style scoped>vue中怎么引用css文件
css·vue.js
向葭奔赴♡41 分钟前
若依系统权限控制全流程解析
前端·javascript·vue.js·ruoyi·navicat
IT_陈寒1 小时前
Python开发者必知的5个高效技巧,让你的代码性能提升50%
前端·人工智能·后端
u***u6851 小时前
Vue虚拟现实案例
前端·vue.js·vr
q***96581 小时前
springboot3整合knife4j详细版,包会!(不带swagger2玩)
android·前端·后端
艾小码1 小时前
Vue 3 defineProps 与 defineEmits 深度解析
前端·javascript·vue.js