使用uni.loadFontFace加载网络字体,小程序开发工具正常,但安卓手机实机无法正常加载。且success和error的回调没有。经摸索,是网络字体的跨域问题。
在宝塔的配置文件里,注意在443下添加,因为小程序要https。
<FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>