fix: root font-size automatic adaptation

This commit is contained in:
zyronon 2024-05-30 10:46:41 +08:00
parent e4a9ce5df3
commit 8dcda1bd10

View File

@ -53,18 +53,19 @@ watch(
} }
) )
function setVh() { function resetVhAndPx() {
let vh = window.innerHeight * 0.01 let vh = window.innerHeight * 0.01
document.documentElement.style.setProperty('--vh', `${vh}px`) document.documentElement.style.setProperty('--vh', `${vh}px`)
document.documentElement.style.fontSize = document.documentElement.clientWidth / 375 + 'px'
} }
onMounted(() => { onMounted(() => {
store.init() store.init()
setVh() resetVhAndPx()
// resize 1vh // resize 1vh
window.addEventListener('resize', () => { window.addEventListener('resize', () => {
location.href = BASE_URL + '/' location.href = BASE_URL + '/'
setVh() resetVhAndPx()
}) })
}) })
</script> </script>