加載本地字體.ttf
將ttf轉(zhuǎn)換為base64格式:https://transfonter.org/
步驟如下
將下載后的stylesheet.css
里的font-family
屬性名字改一下,然后引進(jìn)頁面里就行了,全局樣式就放app.scss,單頁面就引入單頁面
注:文章來源:http://www.zghlxwxcb.cn/news/detail-616804.html
.title {
height: 36rpx;
font-size: 36rpx;
font-family: stylesheet里的名字;
font-weight: bold;
color: #333333;
line-height: 36rpx;
}
加載網(wǎng)絡(luò)字體
好處不超包,壞處比較慢文章來源地址http://www.zghlxwxcb.cn/news/detail-616804.html
wx.loadFontFace({
family: 'yyy',
source: 'url("xxx")',
success: function (e) {
console.log(e, '動(dòng)態(tài)加載字體成功')
},
fail: function (e) {
console.log(e, '動(dòng)態(tài)加載字體失敗')
}
})
到了這里,關(guān)于Failed to load local font resource:微信小程序加載第三方字體的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!