diff --git a/src/App.vue b/src/App.vue index bed79da..6e01317 100644 --- a/src/App.vue +++ b/src/App.vue @@ -53,18 +53,19 @@ watch( } ) -function setVh() { +function resetVhAndPx() { let vh = window.innerHeight * 0.01 document.documentElement.style.setProperty('--vh', `${vh}px`) + document.documentElement.style.fontSize = document.documentElement.clientWidth / 375 + 'px' } onMounted(() => { store.init() - setVh() + resetVhAndPx() // 监听resize事件 视图大小发生变化就重新计算1vh的值 window.addEventListener('resize', () => { location.href = BASE_URL + '/' - setVh() + resetVhAndPx() }) })