muzs

1、新建一个font.js

2、将需要引入的字体上传到云上,必须是https。

3、在font.js中使用微信提供的api下载字体,wx.loadFontFace({})

  // 加载字体
  loadFont() {
    //英文
    wx.loadFontFace({
      family: \'xxxx\', //设置一个font-family使用的名字
      source: \'url("xxx.com/xxxx")\', //字体资源的地址
      success: console.log
    })
    //中文
    wx.loadFontFace({
      family: \'xxxx\',
      source: \'url("https://xxx.com/xxxx.otf")\',
      success: console.log
    })
  },

4、在要使用页面字体的页面下载字体

 const font = require(\'font.js\')
onLoad: function (options) {
    wx.hideShareMenu(); //隐藏转发按钮
    font.loadFont(); //下载字体
  }

5、在wxss中正常使用

  font-family: \'xxxx\';

 

分类:

技术点:

相关文章:

  • 2021-10-31
  • 2021-08-13
  • 2022-12-23
  • 2021-10-25
  • 2021-04-23
  • 2021-09-27
猜你喜欢
  • 2021-05-04
  • 2021-05-01
  • 2021-07-06
  • 2021-11-27
  • 2021-12-31
  • 2021-10-13
  • 2021-12-13
相关资源
相似解决方案