当前位置:网站首页>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; }
边栏推荐
- Problem record in the use of TypeScript
- 简易表白小页面
- 软件测试工作3年了,谈谈我是如何从刚入门进阶到自动化测试的?
- TiDB之rawkv升级之路v5.0.4--&gt;v6.1.0
- 射频器件的基本参数2
- ECCV 2022丨轻量级模型架构火了,力压苹果MobileViT(附代码和论文下载)
- The Meta Metaverse Division lost 2.8 billion in the second quarter, still want to continue to bet?Metaverse development has yet to see a way out
- Basic Parameters of RF Devices 1
- 【网络安全】文件上传靶场通关(1-11关)
- pycharm重命名后无法运行(报错: can‘t open file......No such file or directory)
猜你喜欢
4G通信模块CAT1和CAT4的区别
【952. Calculate the maximum component size according to the common factor】
MySQL高级-六索引优化
Can deep learning solve the parameters of a specific function?
《实战》基于情感词典的文本情感分析与LDA主题分析
tensorflow与GPU版本对应安装问题
35. 反转链表
ShardingSphere read-write separation (8)
软件测试要达到一个什么水平才能找到一份9K的工作?
ECCV 2022 华科&ETH提出首个用于伪装实例分割的一阶段Transformer的框架OSFormer!代码已开源!
随机推荐
小黑leetcode之旅:117. 填充每个节点的下一个右侧节点指针 II
Rocky/GNU之Zabbix部署(3)
权限管理怎么做的?
.NET 跨平台应用开发动手教程 |用 Uno Platform 构建一个 Kanban-style Todo App
关于Redis相关内容的基础学习
Mysql:Invalid default value for TIMESTAMP
斩获BAT、TMD技术专家Offer,我都经历了什么?
I have been working in software testing for 3 years, how did I go from just getting started to automated testing?
link与@import的区别
查看zabbix-release-5.0-1.el8.noarch.rpm包内容
九州云获评云计算标准化优秀成员单位
822. Walk the Grid
VS warning LNK4099: No solution found for PDB
Xiaohei's leetcode journey: 117. Fill the next right node pointer of each node II
PDF 拆分/合并
Installation problem corresponding to tensorflow and GPU version
软件测试要达到一个什么水平才能找到一份9K的工作?
蓝牙mesh系统开发二 mesh节点开发
太阳能板最大面积 od js
Know what DTU is 4GDTU equipment