Skip to content

Commit

Permalink
Update use-reponsive.ts
Browse files Browse the repository at this point in the history
修复QQ浏览器或兼容性错误TypeError: ["xs","sm","md","lg","xl","xxl"].findLast is not a function
  • Loading branch information
298977887 authored and d3george committed Apr 30, 2024
1 parent bda7e39 commit 320045d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/theme/hooks/use-reponsive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 320045d

Please sign in to comment.