微信小程序使用阿里iconfont

准备好图标

image.png

打开在线文件

image.png

拷贝的内容至app.wxss文件,最后替换@font-face为在线连接

image.png

完成

@font-face {
    font-family: 'iconfont';  /* project id 1278443 */
    src: url('//at.alicdn.com/t/font_1278443_27uydgd96pk.eot');
    src: url('//at.alicdn.com/t/font_1278443_27uydgd96pk.eot?#iefix') format('embedded-opentype'),
    url('//at.alicdn.com/t/font_1278443_27uydgd96pk.woff2') format('woff2'),
    url('//at.alicdn.com/t/font_1278443_27uydgd96pk.woff') format('woff'),
    url('//at.alicdn.com/t/font_1278443_27uydgd96pk.ttf') format('truetype'),
    url('//at.alicdn.com/t/font_1278443_27uydgd96pk.svg#iconfont') format('svg');
}
.iconfont {
    font-family: "iconfont" !important;
    font-size: 16px;
    font-style: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
.icon-phone:before {
    content: "\e652";
}
.icon-password:before {
    content: "\e62e";
}

如果不能使用在线文件,可以下载字体文件,转base64格式

打开 https://transfonter.org/

image.png
  1. 点击Add fonts先添加iconfont.ttf文件
  2. 打开Base64 encode
  3. 选择要装换的格式,选中WOFF、WOFF2
  4. 点击转换convert
  5. 装换完成后download
  6. 打开下载后的文件stylesheet.css,复制@font-face

完成

@font-face {
    font-family: 'iconfont';
    src: url(data:application/font-woff2;charset=utf-8;base64,d09GMgABAAAAAAScAA0AAAAACagAAARGAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP0ZGVE0cGh4GVgCCYhEICoY8hSoLEgABNgIkAxgEIAWFCAdgGx0IUVRP2mQ/DnIy6lNCPIWybFHeAm7QytncLH7i4b/9/rfPzLn3zTdNpkApYhVP/1XEQn6NRYLE6qT6K1WjSQn3KqfuJSzJVoECzCpSABENBX52+qJvikw4UYokCX/a0DHTZYJV2tQGdKv0SIxsHk6gQG4W9ZX2/lwh9Pqov6BnKvmEBl4KAR865Rp8eXLWiw8dmMU6UIRqJCQKIsUbHeVVeQ+8hp+P/zSjUXSVuPTm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IkXyJs5buBBBxD2qw+4lUAmFEBea/BV/XjxEUgWvZpIjon00IyO9L+Sq95BV52LdH5udAI+aD4QypIYO827YqcqjSyvcLlm9S6sOHPq9axTTJLJtCSVK1Mjoou/PBib85GBROdLY+E4R/fi5yMx9aAAAAA==) format('woff2'),
        url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAbMAA0AAAAACagAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAGsAAAABoAAAAciDWtFUdERUYAAAaQAAAAHgAAAB4AKQAOT1MvMgAAAZwAAABCAAAAVjyPSERjbWFwAAAB+AAAAFQAAAFizIC2n2dhc3AAAAaIAAAACAAAAAj//wADZ2x5ZgAAAmAAAAKMAAADPKEVLmpoZWFkAAABMAAAADAAAAA2FcLKCWhoZWEAAAFgAAAAHAAAACQH3gOFaG10eAAAAeAAAAAXAAAAGAxSAVpsb2NhAAACTAAAABIAAAASAnoBkm1heHAAAAF8AAAAHwAAACABGQBpbmFtZQAABOwAAAFJAAACiCnmEVVwb3N0AAAGOAAAAE0AAABgsxrE8XjaY2BkYGAAYrNpkfvi+W2+MnCzMIDATY/DbHBa6H8DCwNzA5DLwcAEEgUAFVIJinjaY2BkYGBu+N/AEMPCAAJAkpEBFbAAAEcKAm142mNgZGBg4GCIZWBnAAEmIOYCQgaG/2A+AwAS2AGDAHjaY2BkYWCcwMDKwMDUyXSGgYGhH0IzvmYwYuQAijKwMjNgBQFprikMDs8UnwUxN/xvYIhhbmBoAAozguQA44gMTgAAeNpjYYAAFgh2ZHBgiGQQYjgAAAekAbkAeNpjYGBgZoBgGQZGBhCIAfIYwXwWBgcgzcPAwcDEwPJM8ZnqM71nJs+C/v9nYEDmST6SvC95XfKS5FaoCXDAyMYAF2JkAhJMDGgKGIY9AADWYxSVAAAAAAAAAAAAMABeAKwBNAGeAAB42m1SzWsTURCfmWcTEN2wu9luS2zSzaZJICaYr42laZOAkCgVYyxdbaXppaJtoV40tJdGehD0Ipb2Vo96VfDeKC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yyc1d2oc7D9nu22tNi/a4E1x+xRDWzU/D3bM9JIbAyvkJI18jK3pBJTj2hrrPG7ZynW814IiU68y/SIx5o0dTr3bmniwOLn8owcfbS5kj33qBw+Y1kIeb/dTsQgil2GP5PYcRkAAAB42mNgYoAALjDJyIAOOMCiTIxMjMyMLIysjGxsyUWpiSWp3KXFqUW6yal5JalFHAWJxcXl+UUp3IkFBfmZeSW5QGHWgoz8vFQAlxkReAAAAAAAAAH//wACAAEAAAAMAAAAFgAAAAIAAQADAAcAAQAEAAAAAgAAAAB42mNgYGBkAIKrS9Q5QPRNj8NsMBoAOysFfgAA) format('woff');
    font-weight: normal;
    font-style: normal;
}
.iconfont {
    font-family: "iconfont" !important;
    font-size: 16px;
    font-style: normal;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
.icon-phone:before {
    content: "\e652";
}
.icon-password:before {
    content: "\e62e";
}

你可能感兴趣的:(微信小程序使用阿里iconfont)