比如试图同时显示fontawesome的heart图标和自带alipay图标
@font-face
font-family: 'custom-iconfont-solid'
src: url('./fonts/Font Awesome 5 Free-Solid-900.otf') format('opentype')
@font-face
font-family: 'custom-iconfont-regular'
src: url('./fonts/Font Awesome 5 Free-Regular-400.otf') format('opentype'),
@font-face
font-family: 'custom-iconfont-brands'
src: url('./fonts/Font Awesome 5 Brands-Regular-400.otf') format('opentype')
.van-icon
font-family: 'vant-icon', 'custom-iconfont-solid', 'custom-iconfont-regular', 'custom-iconfont-brands' !important
.van-icon-heart:before
content: '\f004'
显示图标
以上代码显示出两个alipay
如果将css的字体顺序更改为
font-family: 'custom-iconfont-solid', 'custom-iconfont-regular', 'custom-iconfont-brands', 'vant-icon' !important
则显示出两个心💗
以上问题更多出现在button, navtab之类的需要提供图标参数比如 left-arrow/left-icon的地方
原因: 自带alipay的icon 和其他字体共用了一个代码 f004
如何解决:暂时只能覆盖每一处使用van-icon的字体定义,希望能有更方便的方法,比如也许是可以自定义图标的van-icon这个名称