diff --git a/packages/taro-router/src/history/createHistory.ts b/packages/taro-router/src/history/createHistory.ts index 483f94942c38..1f856a25b401 100644 --- a/packages/taro-router/src/history/createHistory.ts +++ b/packages/taro-router/src/history/createHistory.ts @@ -162,7 +162,7 @@ const createHistory = (props: { basename?: string, mode: "hash" | "browser" | "m } function getUserConfirmation(next: Callback, fromLocation: Location, toLocation: Location): void { - const currentRoute = getCurrentRoute() + const currentRoute = getCurrentRoute() || {} const leaveHook = currentRoute.beforeRouteLeave if (typeof leaveHook === 'function') {