From 320045d67323c3f892ba39d918b306d4c5de918c Mon Sep 17 00:00:00 2001 From: 298977887 <127030474+298977887@users.noreply.github.com> Date: Tue, 30 Apr 2024 21:31:55 +0800 Subject: [PATCH] Update use-reponsive.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复QQ浏览器或兼容性错误TypeError: ["xs","sm","md","lg","xl","xxl"].findLast is not a function --- src/theme/hooks/use-reponsive.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/theme/hooks/use-reponsive.ts b/src/theme/hooks/use-reponsive.ts index 9532dc65..56fe3c14 100644 --- a/src/theme/hooks/use-reponsive.ts +++ b/src/theme/hooks/use-reponsive.ts @@ -19,11 +19,12 @@ export function useResponsive() { }; const screenMap: ScreenMap = useBreakpoint(); - const currentScrren = screenArray.findLast((item) => { + // 使用 [...screenArray].reverse().find() 来代替 findLast 方法,避免兼容性问题 + // [...screenArray] 创建了一个 screenArray 的副本,这样 reverse 方法不会改变原数组的顺序 + const currentScrren = [...screenArray].reverse().find((item) => { const result = screenMap[item]; return result === true; }); - return { screenEnum, screenMap,