From 0183c42d6e4f910605f962698014491778ea2eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=A5=A5=E6=96=AF?= <9068149@qq.com> Date: Thu, 4 Nov 2021 15:58:54 +0800 Subject: [PATCH] =?UTF-8?q?pc=E7=AB=AF=E7=9A=84=E5=AE=BD=E5=BA=A6=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E8=AE=BE=E4=B8=BA375px=EF=BC=8C=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=E9=80=82=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/App.vue b/src/App.vue index 7a8e62b..85c6849 100644 --- a/src/App.vue +++ b/src/App.vue @@ -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;' + } + } + }, }