将阿里矢量图添加到element-ui

在阿里矢量图的操作

  1. 选择需要的图标添加至购物车
 
选择图标
  1. 将购物车中的图标, 添加至项目

     
    添加至项目
  2. 会自动跳转到我的项目

     
    项目页面
  3. 更多操作 中选择 编辑项目

     
    更多操作
  4. FontClass/Symbol 前缀 编辑一下, 规范化, 并且不要和 element-ui 中的前缀重名.

    FontFamily 可以随意

     
    编辑项目
  5. 选择 编辑图标, 将图标的名称规范化

     
    编辑单个图标
  6. 修改标签名

     
    修改标签名
  7. 全部完成后, 点击 下载至本地 , 将项目中的图标全部下载下来.

     
    下载项目至本地

     

  8. 下载的文件为一个zip的压缩文件, 加压后可以看到如下内容:

     
    文件内容

项目中的操作

  1. 将文件复制到项目的 assets/icon 目录下

     
    复制图标文件
     
    2.修改 iconfont.css 文件
    [class^="el-icon-newfont"], [class*=" el-icon-newfont"] {
      font-family: "FontFamily" !important;
      font-size: 12px;
      font-style: normal;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }

     

    注意: 第二个 class 中有个空格, font-size 可以调整图标字体的大小

    iconfont.css 文件的所有内容如下:

     

    @font-face {
        font-family: "FontFamily";
        src: url('iconfont.eot?t=1594950973013'); /* IE9 */
        src: url('iconfont.eot?t=1594950973013#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAA/4AAsAAAAAG2gAAA+oAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCEUgqnKJ5kATYCJAM0CxwABCAFhQUHgUAbQBajooaSVuBkf5XAgyH1G1kUQxFKt2qKgXGBQSc0y6mFLNuPnuWbPiN6OZHrlBOEW5JHfSil/99+rPv+vBnHVJpl00woRJUEIXI6ncjphEjSD9FW0u78uZafAqCKLxHYm3T3BZZyoSPhqyqrRI2pJBCutv2feei9/dtdGSeQJJT0RllsEQ94QUPvlZ/p80zrYHFXJruVMHig9yH5TX6hg6MKCAZom12RoT1hIEYNAaOBI6wpRi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Fvy977fpd9Y4Ps8za0L5bEbVi49FqMQdtlicJLY0308btHdqdqWqYMa3sHF+RFLYvOVywD/vsOUCGeQwBY7TQ8gOfBnIZ6cQKubljGC+CEVOyHt8CyqTdTZ8VxeFbTQLyX9wLHf3Gb78RB/B8PCkkR4Mvf2YKvqP+G6GG4e3p8fWbN/jbon6RdjxON4xpWB4XyGNthJKINBLc/Jyz0/xvg8TpEIxn1GTRisgfx+IbHR/wbrfvLiCpoyohV1DyaABy7Cbjx2Zzrox6rIDexwEX8Ly0JrapFcBpVzu9ukbzRFsWZanHaHCzv5SkoQWUBtLp8tJB8Ny2JTA8gePnPwMj/bJEKgzSF8ihqcZaiR9JrjEO3ooFY8PFFHgtPJpTcVq+b37ZOYhHlj4G5iOjYSd63nIM2QiZ4qLM7ZWoDEtCqkpsMG7aWYqpljOUvBlEkcVrLADzbz61NTw90bfLm7fdkjKpN0ABhrY4+7EK+p+CREnTSqjbteVlHxIRI3jHAuNe7E1p6xqR4DmgGhH//2JB+g7nUDSPJedq2iUYGM/w9alHYAE0g9oZUcBCxcQlL8yEg4L2s78dLjKZNG2CXo3mN/l5b8fIH4Czo2mREQoKYJCnSZMiSI0+BMigT+iKGu8A1TK5EKha+H0GWaKjyuDNc1HOTKi6NTYlE2CqTN8yRJBKVW3suVM+WWwyWgzO1BZFP+nnfUu5LLwRdHJpW6bekIslkimnIV1cSQggAAAA=') format('woff2'),
        url('iconfont.woff?t=1594950973013') format('woff'),
        url('iconfont.ttf?t=1594950973013') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */ url('iconfont.svg?t=1594950973013#FontFamily') format('svg'); /* iOS 4.1- */
    }
    
    .FontFamily {
        font-family: "FontFamily" !important;
        font-size: 16px;
        font-style: normal;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    [class^="el-icon-newfont"], [class*=" el-icon-newfont"] {
        font-family: "FontFamily" !important;
        font-size: 18px;
        font-style: normal;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    .el-icon-newfontdashuju:before {
        content: "\e602";
    }
    
    .el-icon-newfonticon_middleware:before {
        content: "\e604";
    }
    
    .el-icon-newfontchushihua:before {
        content: "\e74d";
    }
    
    .el-icon-newfonthost_init:before {
        content: "\e600";
    }
    
    .el-icon-newfontsysguanli:before {
        content: "\e620";
    }
    
    .el-icon-newfontIMguanli:before {
        content: "\e69b";
    }
    
    .el-icon-newfontprometheus:before {
        content: "\e64f";
    }
    
    .el-icon-newfontziyuanguanli:before {
        content: "\e83f";
    }
    
    .el-icon-newfontdocker:before {
        content: "\e64c";
    }
    
    .el-icon-newfontks:before {
        content: "\e62b";
    }
    
    .el-icon-newfontprometheus_logo_grey:before {
        content: "\e603";
    }
    
    .el-icon-newfontmiddleware:before {
        content: "\e610";
    }

     

     

 

   3. 在 main.js 中引入 iconfont.css 文件

    

import '@/assets/icon/iconfont.css'

 
引入样式文件
  1. 使用图标

    icon 引用:

    <el-button type="primary"
        title="管理公众号"
        icon="el-icon-newfont-setting" //图标名
        size="mini"
        @click="manage(scope.row.appId)"
        circle/>

     

    class 引用:

    <el-button type="primary"
        title="管理公众号"
        class="el-icon-newfont-setting" //图标名
        size="mini"
        @click="manage(scope.row.appId)"
        circle/>

     

在线引入css

 
获取在线样式地址

vue 项目中的 App.vue 文件中添加这个引用(每次添加新图标到 iconfont 中的购物车、项目之后更新这个链接即可)

less 样式引入

</style>
<style lang="less" scoped>
@import url(//at.alicdn.com/t/font_1026187_okd0aeilrwg.css);
</style>

 

el-input 上使用图标

<el-input
    placeholder="设置"
    suffix-icon="el-icon-newfont-setting"
    v-model="input2">
</el-input>
 

 

参考:https://www.jianshu.com/p/1f1ca6f452b4

posted @ 2020-07-17 10:07  醒日是归时  阅读(1521)  评论(0编辑  收藏  举报