pc端的宽度显示设为375px,移动端适应

This commit is contained in:
王奥斯
2021-11-04 15:58:54 +08:00
parent 9864c07fa7
commit 0183c42d6e
+16 -1
View File
@@ -24,7 +24,22 @@ export default {
this.isRouterAlive = true
})
},
}
},
mounted() {
// 判断是否为移动端
if (
!navigator.userAgent.match(
/(iPhone|iPod|Android|ios|iOS|iPad|Backerry|WebOS|Symbian|Windows Phone|Phone)/i
)
) {
// pc端的宽度显示设为375px
let html = document.querySelector('html')
html.style = 'font-size: 37.5px;width: 375px; margin: 0 auto;'
window.onresize = () => {
html.style = 'font-size: 37.5px;width: 375px; margin: 0 auto;'
}
}
},
}
</script>
<style lang="less">