diff --git a/pages/API/load-font-face/load-font-face.js b/pages/API/load-font-face/load-font-face.js new file mode 100644 index 0000000..c819939 --- /dev/null +++ b/pages/API/load-font-face/load-font-face.js @@ -0,0 +1,35 @@ +// pages/API/load-font-face/load-font-face.js +Page({ + data: { + fontFamily: 'Bitstream Vera Serif Bold', + loaded: false, + }, + + onLoad() { + this.setData({ + loaded: false + }) + }, + + loadFontFace() { + const self = this + wx.loadFontFace({ + family: this.data.fontFamily, + source: 'url("https://sungd.github.io/Pacifico.ttf")', + success(res) { + console.log(res.status) + self.setData({loaded: true}) + }, + fail(res) { + console.log(res.status) + }, + complete(res) { + console.log(res.status) + } + }) + }, + + clear() { + this.setData({loaded: false}) + } +}) diff --git a/pages/API/load-font-face/load-font-face.json b/pages/API/load-font-face/load-font-face.json new file mode 100644 index 0000000..4181ec1 --- /dev/null +++ b/pages/API/load-font-face/load-font-face.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "动态加载字体" +} diff --git a/pages/API/load-font-face/load-font-face.wxml b/pages/API/load-font-face/load-font-face.wxml new file mode 100644 index 0000000..9f26555 --- /dev/null +++ b/pages/API/load-font-face/load-font-face.wxml @@ -0,0 +1,23 @@ + + + + + +