微信小程序引入iconfont

微信小程序如何引用阿里iconfont图标库?

1、进入阿里iconfont官网 https://www.iconfont.cn/;新建一个自己的项目,导入自己需要的icon。
在这里插入图片描述
2、将项目里的icon库下载至本地、解压。
解压后的文件列表

3、打开https://transfonter.org/,来转换 ttf 。
点击Add fonts,上传iconfont.ttf。
在这里插入图片描述
4、勾选上 Family support , Base64 encode, TTF 三个选项, 点击 “Convert” 进行转化, 然后 “Download”。
5、解压后的目录:
在这里插入图片描述
6、将stylesheet.css的内容拷贝至小程序的app.wxss中,将之前在iconfont下载的文件夹打开,找到iconfont.css,将其中的.iconfont {...}和带:before的所有伪类CSS代码拷贝至小程序的app.wxss。完成后的app.wxss内容如下:

@font-face {
    font-family: 'iconfont';
    src: url('data:application/font-woff2;charset=utf-8;base64,d09GMgABAAAAAAyYAA0AAAAAGOAAAAxDAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP0ZGVE0cGh4GVgCCUhEICqUYnC8LEAABNgIkAxYEIAWFCAdNG30To6J2cVZUsn8kxkTmfGEXlcrjtjk7y9qOyLIovNAclw6f+H/D0zb/PfI4ME6wijASEKMJM0CMImphYtQfbu0ilVW6qGBZLkPX/Qmq297fzYO8c9RMwmkWYCCpJgnckJvWrrad1G18l+kdeJdlSlaychxWxxJqIif7z7fWvs4g6oNGQrFIs1AoaW5O58x2Fx1Ek6hHS5TAI7qkhUbj0cQytZDC7+Uv1dkmC6jKjFs/PieGAwBgMxhY6YsUsXfzJFpCUhpCB4rbyohHAhEYALA8/xsQhQt3PtZOH9vAP48fCHtjYoLq1LwjWQ2EHzK0n6b/Tcp7E+hGZ6jDZzq3PZilgYE/AfciBAIHDCKDJUPnumcH3Kr0t/Nbp1g5ZcXBabIcwHHJo/CfB3LKYfdNO5KhNZjkRlre5C0roT+NExnbss2lyFMoNjmPRTrt8HQH+nS6k72DNJVm5YbEWLG9PbycWMi8nRwZUSLZBoVWBlpJoGhWkKLkzyQklOjersOGZN3R2wtI5xzUuqcPkrvNjrU+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42n2QPU4DMRCFn/MHJBJCIKhdUQDa/JQpEyn0CKWjSDbekGjXXnmdSDkBLRUHoOUYHIAbINFyCl6WSZMia+3o85uZ57EBnOMbCv/fJe6EFY7xKFzBETLhKvUX4Rr5XbiOFj6FG9R/hJu4VQPhFi7UGx1U7YS7m9JtywpnGAhXcIon4Sr1lXCN/CpcxxU+hBvUv4SbGONXuIVrZakM4WEwQWCcQWOKDeMCMRwskjIG1qE59GYSzExPN3oRO5s4GyjvV2KXAx5oOeeAKe09t2a+Sif+YMuB1JhuHgVLtimNLiJ0KBtfLJzV3ahzsP2e7ba02L9rgTXH7FENbNT8Pdsz0khsDK+QkjXyMrekElOPaGus8btnKdbzXgiJTrzL9IjHmjR1OvduaeLA4ufyjBx9tLmSPfeoHD5jWQh5v91OxCCKXYY/k9hxGQAAAHjaY2BigAAuMMnIgA7YwaJMjEyMzIwsjKxsVZk5mYn5bMUZpcmJmexAKjO9NB8oWlmamAcAovYK7AAAAAAAAAH//wACAAEAAAAMAAAAFgAAAAIAAQADAAYAAQAEAAAAAgAAAAB42mNgYGBkAIKrS9Q5QPTtAOc0GA0AOXsFUgAA') format('woff'),
        url('iconfont.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.iconziliao:before {
  content: "\e608";
}

.iconziyuan:before {
  content: "\e7cb";
}

.iconshucai:before {
  content: "\e617";
}

.iconshuiguo:before {
  content: "\e618";
}

7、大功告成,可以使用iconfont了:

<text class="iconfont iconshuiguo"></text>

效果如下:
在这里插入图片描述
任何时候都不要放弃成为更好的自己!加油·小汪!

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页