- 进入阿里巴巴矢量图标库
- 选择自己的图标,添加到创建的项目中
3.下载至本地,解压后文件如下
4.转换ttf文件,在 transfonter.org/ 中转换,上传 iconfont.ttf
5.勾选 Family support , Base64 encode, TTF 三个选项, 点击 "Convert" 进行转化, 然后 "Download"
6.解压目录如下
7.找到 stylesheet.css
把里面的内容拷贝到 小程序 的 app.wxss
中, 打开之前在 IconFont 网站中下载的文件,找到 iconfont.css
,复制 .iconfont{}
和 带有伪类选择器 :before
的相关 css 到 app.wxss
最终 app.wxss 中代码如下
/**app.wxss**/ @font-face {font-family: "iconfont"; src: url('iconfont.eot?t=1547017854006'); /* IE9 */ src: url('iconfont.eot?t=1547017854006#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAc4AAsAAAAADdgAAAbqAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCECgqNRIpuATYCJAMkCxQABCAFhG0HgQobpAsRFaxHIPv6QLu0P9WAcoIS/LK7poR7Hj07h7EpJZL6OaNwe38vCfKSIBaoiiOtAxUR2nlJ69B6BPrFnlMV5VuFb8rimm17YuEi1JGcffLoD9I2V8h9mo4CgIe33fvupipFVExXSFlSwoUom4BQ1KYoGv6fhjFsA5hk34OiwNMyo0Hzh/ulXpQeWL6rRTldZtKi+GgFNKCIthvgB137wHCLeI5oJ+d7Jh58GAiAVVpNZO7c0wsjBpETtmwdPzYEY86AqSETRrUeuDCDbNAxVquoKwDWhR9PPtQPI0DRJZBH9V06jULbF+/G0GJGxNAkQuzPBkC6DKABNQEMkB10yKBjWc1QwUK1jHEAOyv/N6kXqRKpZqnOqWTq+rue78ZkKvcjgwg7rQdoDD0y/f88BkYgNTgFz+KnJY2QgjsKNKRKjAIDqWajoIdU51EgkEqOAgWp66Ogg3c9R8EA78YYYGSxWbV2QHmgRlZ1sPiWDgNyT+yol0WHagUrw5MRxUnJ7i2YuMlW1spQ5JQQeBNvc0/mo6dK67443cSy92YpRp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oEib5Pdk71AsC+QJ3APMe3xbZ9bNkgmqa2+LIBC3b4sq/ZVtJm7gtEO7INFhdU612OBGbPDnhSIhpJID253JuNU6bEi5cvvirvu5J9+5486apKhgWtcsw2M9ryfG2Z9XyshO1G8AZbaEZTbQWrUaLeXDZ+S/U4p+3+ZOsn8Q0r/+KPbmxy5O1vyfgKt3Zh65z64b+xLwCQyXG6bUiFdtLZVOnRdLv99zG6FgDQJ5XGYE6UAPRNnfjGH4Stp/9bO8LS8jcj9yuw5sGQ44t4fwYG/RXBiAK08PstRM5iTDGRZVlLgito4cqy4F0fowAsXQV8qz12z/pVudAK/I2oXClQDEoBzagimsHXBB1OQ9AzagOsGrpcznGYgUZyFoDqljFAWG0HitlxoFldRTP4p6AjeA961qCB5Q/HDTmVQ0e3r4K94gTDEWjkZByz3kblX2hL6CUrDil/KJnC0FZNMf2JCaWPU/LOdqoGjHCED+ZxGALDIjzjqJVTXbZ1baBTq5Hj6havgr36nBMMx5k0cjKD9bb0/l9oS+ilpq8x8w8l0/ahrRoE+lORUH3nUpt3tlPOZsBtFY7wwdkw0ATDAu8346iVaxFbtjU3n8EqqvFV8bbegvQgQzwSmKRohuV43U+gJJzsiQ4l3R65zNQnDXTn/yL1OlAJR9obR1nZSh9fsDmu9Gl0sOzS57Wj3ZwcHuxltQIA') format('woff2'), url('iconfont.woff?t=1547017854006') format('woff'), url('iconfont.ttf?t=1547017854006') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */ url('iconfont.svg?t=1547017854006#iconfont') format('svg'); /* iOS 4.1- */ } .iconfont { font-family: "iconfont" !important; font-size: 16px; font-style: normal; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } .icon-jinrongzixun:before { content: "\e646"; } .icon-youjiantou:before { content: "\e6ab"; } .icon-qian:before { content: "\e600"; } .icon-liuliang:before { content: "\e61b"; } .icon-histogram:before { content: "\e6cf"; } .icon-jinrongzhuanchang:before { content: "\e639"; } .icon-chaxun:before { content: "\ec4c"; } .icon-zhexiantu:before { content: "\ec66"; }
在 index.wxml
中可以使用 text
和 span
显示字体图标
<text class="iconfont icon-jinrongzixun"></text> <span class="iconfont icon-jinrongzixun"></span>