From 357ed6cf12059166a56b4341d75df9d46e6cd477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8F=B2=E9=B8=BD?= <1020103647@qq.com> Date: Fri, 28 Jun 2024 13:07:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(arr.at):=20=E4=BD=8E=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=AE=89=E5=8D=93=E6=B5=8F=E8=A7=88=E5=99=A8=E6=89=93=E5=8C=85?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 1247dc6..21eb57e 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,4 +1,11 @@ import { pages, subPackages, tabBar } from '@/pages.json' +const getLastPage = () => { + // getCurrentPages() 至少有1个元素,所以不再额外判断 + // const lastPage = getCurrentPages().at(-1) + // 上面那个在低版本安卓中打包回报错,所以改用下面这个【虽然我加了src/interceptions/prototype.ts,但依然报错】 + const pages = getCurrentPages() + return pages[pages.length - 1] +} /** 判断当前页面是否是tabbar页 */ export const getIsTabbar = () => { @@ -9,8 +16,7 @@ export const getIsTabbar = () => { // 通常有tabBar的话,list不能有空,且至少有2个元素,这里其实不用处理 return false } - // getCurrentPages() 至少有1个元素,所以不再额外判断 - const lastPage = getCurrentPages().at(-1) + const lastPage = getLastPage() const currPath = lastPage.route return !!tabBar.list.find((e) => e.pagePath === currPath) } @@ -21,8 +27,7 @@ export const getIsTabbar = () => { * redirectPath 如 ‘/pages/demo/base/route-interceptor’ */ export const currRoute = () => { - // getCurrentPages() 至少有1个元素,所以不再额外判断 - const lastPage = getCurrentPages().at(-1) + const lastPage = getLastPage() const currRoute = (lastPage as any).$page // console.log('lastPage.$page:', currRoute) // console.log('lastPage.$page.fullpath:', currRoute.fullPath)