From 06f942d0fbe1c5c86dc7e17d38c00d595854bd4f Mon Sep 17 00:00:00 2001 From: yuangongji <82787816@qq.com> Date: Fri, 5 Feb 2021 05:25:55 +0800 Subject: [PATCH] fix(guards): vue-class-component call guards on first... (#755) navigation with lazy routes --- src/navigationGuards.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/navigationGuards.ts b/src/navigationGuards.ts index 6c6316d6..c7a872d1 100644 --- a/src/navigationGuards.ts +++ b/src/navigationGuards.ts @@ -316,8 +316,10 @@ export function extractComponentsGuards( : resolved // replace the function with the resolved component record.components[name] = resolvedComponent - // @ts-ignore: the options types are not propagated to Component - const guard: NavigationGuard = resolvedComponent[guardType] + // __vccOpts is added by vue-class-component and contain the regular options + let options: ComponentOptions = + (resolvedComponent as any).__vccOpts || resolvedComponent + const guard = options[guardType] return guard && guardToPromiseFn(guard, to, from, record, name)() }) ) -- 2.39.5