当前位置:网站首页>uniapp使用第三方字体
uniapp使用第三方字体
2022-07-31 01:34:00 【九亿宅男的梦】
一、CSS远程加载
App.vue
@font-face{
font-family: font-name;
src:url('https://XXXXX/font.ttf');
}
在微信小程序的开发者工具里面有用,但是(安卓)真机调试没有用
二、引入本地字体,太大小程序会无法上传---font.ttf文件转换成base64格式
使用
<style lang="scss">
/*每个页面公共css */
@import "@/static/zt.css";
.YouSheBiaoTiHei{
font-family: 'YouSheBiaoTiHei';
}
</style>
三、使用API uni.loadFontFace()
App.vue
onLaunch: function () {
uni.loadFontFace({
global: true, // 是否全局生效
family: 'font-name', // 定义的字体名称
source: 'url("https://xxx.com/font/font-name.ttf")', // 字体资源的地址。建议格式为 TTF 和 WOFF,WOFF2 在低版本的iOS上会不兼容。
success() {
console.log('成功的回调函数')
},
fail(){
console.log('失败的回调函数')
},
complete(){
console.log('接口调用结束的回调函数(调用成功、失败都会执行)')
}
})
},
API说明:uni.loadFontFace(Object object) | uni-app官网,微信小程序的开发文档也有对应的方法,需要特别注意的是:
另外还有注意的是在这个讨论中wx.loadFontFace加载字体,安卓真机fail,模拟器和ios真机正常 | 微信开放社区 ,小程序技术专员提到的
运用字体网站 下载-字体天下
使用 .font-name { font-family: font-name; }
边栏推荐
- 手把手教你配置Jenkins自动化邮件通知
- 聚簇索引和非聚簇索引到底有什么区别
- Jiuzhou Cloud was selected into the "Trusted Cloud's Latest Evaluation System and the List of Enterprises Passing the Evaluation in 2022"
- Shell变量与赋值、变量运算、特殊变量
- Zabbix干啥用?
- MySql的安装配置超详细教程与简单的建库建表方法
- Typescript18 - object type
- I have been working in software testing for 3 years, how did I go from just getting started to automated testing?
- Chi-square distribution of digital image steganography
- 数字图像隐写术之卡方分布
猜你喜欢
随机推荐
Installation problem corresponding to tensorflow and GPU version
87. Convert String to Integer
Typescript18 - object type
【Map与Set】之LeetCode&牛客练习
MySQL高级-六索引优化
《MySQL数据库进阶实战》读后感(SQL 小虚竹)
爬虫文本数据清洗
九州云获评云计算标准化优秀成员单位
MySQL (6)
蛮力法/邻接表 广度优先 有向带权图 无向带权图
ShardingSphere read-write separation (8)
权限管理怎么做的?
822. Walk the Grid
C语言_结构体指针数组函数选票系统
Jiuzhou Cloud was selected into the "Trusted Cloud's Latest Evaluation System and the List of Enterprises Passing the Evaluation in 2022"
进程间通信学习笔记
系统设计.短链系统设计
In Google Cloud API gateway APISIX T2A and T2D performance test
87. 把字符串转换成整数
What have I experienced when I won the offer of BAT and TMD technical experts?