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

This commit is contained in:
菲鸽 2024-03-18 09:27:50 +08:00
parent 9b8800ba02
commit 185c5df24d

View File

@ -8,6 +8,13 @@ export const getIsTabbar = () => {
return false return false
} }
const pages = getCurrentPages() 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) 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]
}