From 83e08353ebe13ca581db39b6340174fdb47a46b9 Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Mon, 1 Sep 2025 15:55:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(utils):=20=E5=A4=84=E7=90=86=E6=9C=AA?= =?UTF-8?q?=E6=89=BE=E5=88=B0lastPage=E6=97=B6=E7=9A=84currRoute=E8=BF=94?= =?UTF-8?q?=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当getLastPage返回undefined时,currRoute现在会返回包含空path和空query的默认对象,避免潜在的运行时错误 --- src/utils/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/index.ts b/src/utils/index.ts index 37c240f..3ff0a40 100644 --- a/src/utils/index.ts +++ b/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)