fix: root font-size automatic adaptation
This commit is contained in:
parent
e4a9ce5df3
commit
8dcda1bd10
@ -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()
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user