以Promise风格调用: 支持
动态加载网络字体,文件地址需为下载类型。全局生效需在 app.js 中调用。
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
family | string | 否 | 字体名称 | |
source | string | 否 | 字体资源地址 | |
desc | object | 否 | 字体描述 | |
global | boolean | false | 否 | 是否全局生效 |
scopes | array | webview | 否 | 字体作用范围,可选值为 webview / native,默认 webview,设置 native 可在 Canvas 2D 下使用 |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
---|---|---|
errMsg | string |
xhs.loadFontFace({ family: 'Bitstream Vera Serif Bold', source: 'url("https://sungd.github.io/Pacifico.ttf")', success: console.log })