From 754edac71a79ea37077447fd94765e1a48385d13 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Fri, 16 Jun 2023 19:17:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=A9=E6=94=BE=E5=8F=AF=E4=BB=A5=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E6=A3=80=E6=B5=8B=E6=98=AF=E5=90=A6=E6=A8=AA=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugin/use.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugin/use.ts b/src/plugin/use.ts index 5f8887a..f5f8863 100644 --- a/src/plugin/use.ts +++ b/src/plugin/use.ts @@ -16,7 +16,13 @@ const dragFnMap = new Map(); /** * 是否是移动设备 */ -export const isMobile = matchMedia('(max-width: 600px)').matches; +export let isMobile = matchMedia('(max-width: 600px)').matches; + +window.addEventListener('resize', () => { + requestAnimationFrame(() => { + isMobile = matchMedia('(max-width: 600px)').matches; + }); +}); /** * 向一个元素添加拖拽事件