W***@163.COM
W***@163.COM
  • 发布:2025-01-22 21:56
  • 更新:2025-01-22 21:56
  • 阅读:33

uni.loadFontFace 引入外部字体没有效果,外部链接是带https的并且后台配了成合法域名也不行

分类:uni-app

uni.loadFontFace 引入外部字体没有效果,外部链接是带https的并且后台配了成合法域名也不行
小程序中使用
const fontUrl=${process.env.APP_URL}/static/11/fonts/montserrat-Black.ttf;
//const fontUrl=/static/assets/font/montserrat-Black.ttf
console.log("字体",fontUrl)
uni.loadFontFace({
global:true,
family: 'haipai',
source: url("${fontUrl}"),
success() {
console.log('success')
}
})

在<style>里边

@font-face {
font-family: 'haipai';
src: url('https://www5324s.s7.tunnelfrp.com/static/11/fonts/montserrat-Black.ttf');
font-weight: normal;
font-style: normal;
font-display: auto;
}

.name {
width: 100%;
height: 20px;
font-size: 16x;
color: #e1251b;
overflow: hidden;
font-family: 'haipai'
}

引入没有效果 ,外部字体大小是超过1M多的。

2025-01-22 21:56 负责人:无 分享
已邀请:

要回复问题请先登录注册