Selaa lähdekoodia

fix(utils): 处理未找到lastPage时的currRoute返回

当getLastPage返回undefined时,currRoute现在会返回包含空path和空query的默认对象,避免潜在的运行时错误
feige996 8 kuukautta sitten
vanhempi
commit
83e08353eb
1 muutettua tiedostoa jossa 6 lisäystä ja 0 poistoa
  1. 6 0
      src/utils/index.ts

+ 6 - 0
src/utils/index.ts

@@ -16,6 +16,12 @@ export function getLastPage() {
  */
 export function currRoute() {
   const lastPage = getLastPage()
+  if (!lastPage) {
+    return {
+      path: '',
+      query: {},
+    }
+  }
   const currRoute = (lastPage as any).$page
   // console.log('lastPage.$page:', currRoute)
   // console.log('lastPage.$page.fullpath:', currRoute.fullPath)