From: yuangongji <82787816@qq.com> Date: Thu, 4 Feb 2021 21:25:55 +0000 (+0800) Subject: fix(guards): vue-class-component call guards on first... (#755) X-Git-Tag: v4.0.4~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=06f942d0fbe1c5c86dc7e17d38c00d595854bd4f;p=thirdparty%2Fvuejs%2Frouter.git fix(guards): vue-class-component call guards on first... (#755) navigation with lazy routes --- 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)() }) )