]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
feat(types): export NavigationGuardNext (#229)
authorCédric Exbrayat <cexbrayat@users.noreply.github.com>
Mon, 11 May 2020 07:05:54 +0000 (09:05 +0200)
committerGitHub <noreply@github.com>
Mon, 11 May 2020 07:05:54 +0000 (09:05 +0200)
src/index.ts
test-dts/createRouter.test-d.ts

index 00f5554f88c7bea8e0e6caaf1b166c28982947ee..54473dee253f647547155fd65cf994c1088ffb46 100644 (file)
@@ -31,6 +31,7 @@ export {
   RouteLocationOptions,
   RouteRecordRaw,
   NavigationGuard,
+  NavigationGuardCallback,
   PostNavigationGuard,
 } from './types'
 export {
index 44a97244f1d1b7b98c08a0ba7daf0a8961efac41..1af67c2f1d02966603d3e603fb9cb8463e1f2d83 100644 (file)
@@ -1,4 +1,10 @@
-import { createRouter, createWebHistory } from './index'
+import {
+  createRouter,
+  createWebHistory,
+  NavigationGuard,
+  NavigationGuardCallback,
+  RouteLocationNormalized,
+} from './index'
 import { createApp, defineComponent } from 'vue'
 
 const component = defineComponent({})
@@ -14,5 +20,15 @@ const router = createRouter({
   scrollBehavior(to, from, savedPosition) {},
 })
 
+export const loggedInGuard: NavigationGuard = (to, from, next) => next('/')
+function beforeGuardFn(
+  to: RouteLocationNormalized,
+  from: RouteLocationNormalized,
+  next: NavigationGuardCallback
+) {}
+
+router.beforeEach(loggedInGuard)
+router.beforeEach(beforeGuardFn)
+
 const app = createApp({})
 app.use(router)