]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
fix(guards): vue-class-component call guards on first... (#755)
authoryuangongji <82787816@qq.com>
Thu, 4 Feb 2021 21:25:55 +0000 (05:25 +0800)
committerGitHub <noreply@github.com>
Thu, 4 Feb 2021 21:25:55 +0000 (22:25 +0100)
navigation with lazy routes

src/navigationGuards.ts

index 6c6316d6924918c8268bc94523af6ea5a10b7e8b..c7a872d15826d7a0be488d6a486a9ce212e39024 100644 (file)
@@ -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)()
           })
         )