Explorar o código

fix: getCurrentPages(...).at is not a function

菲鸽 %!s(int64=2) %!d(string=hai) anos
pai
achega
185c5df24d
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  1. 8 1
      src/utils/index.ts

+ 8 - 1
src/utils/index.ts

@@ -8,6 +8,13 @@ export const getIsTabbar = () => {
     return false
   }
   const pages = getCurrentPages()
-  const currPath = pages.at(-1).route
+  const lastPage = getArrElementByIdx(pages, -1)
+  const currPath = lastPage.route
   return !!pagesJson.tabBar.list.find((e) => e.pagePath === currPath)
 }
+
+export const getArrElementByIdx = (arr: any[], index: number) => {
+  if (index < 0) return arr[arr.length + index]
+  if (index >= arr.length) return undefined
+  return arr[index]
+}