字体适配

This commit is contained in:
tcubic
2022-08-05 17:01:41 +08:00
parent ef0b91c95c
commit 434c3af16d
2 changed files with 28 additions and 1 deletions

View File

@@ -24,6 +24,7 @@
<!-- <div class="prize p-3" ref="p20"></div> -->
</div>
<!-- <div class="btn" @click="btn">开始抽奖</div> -->
</div>
</div>
</template>

View File

@@ -210,7 +210,9 @@ onBeforeMount(() => {
});
// 页面挂载
onMounted(() => {});
onMounted(() => {
fontAdpat()
});
// 来自首页的事件
const indexPage = (actions) => {
@@ -284,6 +286,30 @@ const pageImgsArrLoad = (imgs) => {
});
return Promise.all(promiseArr);
};
// 字体适配
const fontAdpat = ()=>{
if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") {
handleFontSize();
} else {
if (document.addEventListener) {
document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
} else if (document.attachEvent) {
document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
}
}
function handleFontSize() {
// 设置网页字体为默认大小
WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
// 重写设置网页字体大小的事件
WeixinJSBridge.on('menu:setfont', function() {
WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
});
}
}
</script>
<style lang="scss" scoped>