公共组件库
BaseIcon

BaseIcon

  • 字体图标组件 BaseIcon

组件使用

  • icon-name: 字体图标名称 (必填)
  • size?: 大小
  • color?: 颜色
<BaseIcon icon-name="icon-notice" color="#999" />

组件实现

<template>
  <svg class="icon" aria-hidden="true" :style="{ fontSize: size, color }">
    <use :xlink:href="icon" />
  </svg>
</template>
 
<script>
export default {
  name: 'BaseIcon',
  props: {
    iconName: {
      type: String,
      required: true,
    },
    size: {
      type: [Number, String],
      default: 16,
    },
    color: [String],
  },
  computed: {
    icon() {
      return `#${this.iconName}`;
    },
  },
};
</script>
 
<style scoped lang="scss">
.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>

如何添加新图标

  • 先找管理员申请 iconfont (opens in a new tab) 项目权限
  • 进入 base-icon项目,上传新图标, 尽量编辑图标,移除图标空白,然后在保存,设置好图标名称
  • 选择 Symbol 生成js代码,然后上传到阿里云 (请把生成好的js文件发送给管理员,由管理员上传至阿里云OSS即可)
  • iocnfont.js文件上传好后,即可在项目使用