fix(arr.at): 低版本安卓浏览器打包报错

This commit is contained in:
菲鸽 2024-06-28 13:07:45 +08:00
parent 24240c16f4
commit 357ed6cf12

View File

@ -1,4 +1,11 @@
import { pages, subPackages, tabBar } from '@/pages.json' 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页 */ /** 判断当前页面是否是tabbar页 */
export const getIsTabbar = () => { export const getIsTabbar = () => {
@ -9,8 +16,7 @@ export const getIsTabbar = () => {
// 通常有tabBar的话list不能有空且至少有2个元素这里其实不用处理 // 通常有tabBar的话list不能有空且至少有2个元素这里其实不用处理
return false return false
} }
// getCurrentPages() 至少有1个元素所以不再额外判断 const lastPage = getLastPage()
const lastPage = getCurrentPages().at(-1)
const currPath = lastPage.route const currPath = lastPage.route
return !!tabBar.list.find((e) => e.pagePath === currPath) return !!tabBar.list.find((e) => e.pagePath === currPath)
} }
@ -21,8 +27,7 @@ export const getIsTabbar = () => {
* redirectPath /pages/demo/base/route-interceptor * redirectPath /pages/demo/base/route-interceptor
*/ */
export const currRoute = () => { export const currRoute = () => {
// getCurrentPages() 至少有1个元素所以不再额外判断 const lastPage = getLastPage()
const lastPage = getCurrentPages().at(-1)
const currRoute = (lastPage as any).$page const currRoute = (lastPage as any).$page
// console.log('lastPage.$page:', currRoute) // console.log('lastPage.$page:', currRoute)
// console.log('lastPage.$page.fullpath:', currRoute.fullPath) // console.log('lastPage.$page.fullpath:', currRoute.fullPath)