From: Eduardo San Martin Morote Date: Fri, 27 Sep 2019 08:20:27 +0000 (+0200) Subject: feat: prepare callback for NavigationGuardCallback X-Git-Tag: v4.0.0-alpha.0~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31c07dbdf3904e3069783dad52db4113fd3070b9;p=thirdparty%2Fvuejs%2Frouter.git feat: prepare callback for NavigationGuardCallback --- diff --git a/explorations/html5.html b/explorations/html5.html index 18d096bc..79b8c191 100644 --- a/explorations/html5.html +++ b/explorations/html5.html @@ -85,6 +85,9 @@ +
  • + /with-data +
  • +

    Here is the data: {{ data }}

    + `, + // @ts-ignore + data: () => ({ data: 'nope' }), + beforeRouteEnter(to, from, next) { + console.log('this in beforeRouteEnter', this) + setTimeout(() => { + next(vm => { + console.log('got vm', vm) + vm.data = 'Hola' + }) + }, 300) + }, +} + if ('scrollRestoration' in history) { history.scrollRestoration = 'manual' } @@ -118,6 +135,7 @@ const router = new Router({ { path: 'b', name: 'b-child', component }, ], }, + { path: '/with-data', component: ComponentWithData, name: 'WithData' }, // { path: /^\/about\/?$/, component }, ], async scrollBehavior(to, from, savedPosition) { diff --git a/src/types/index.ts b/src/types/index.ts index 782b57d8..614794e7 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -182,6 +182,7 @@ export interface NavigationGuardCallback { (): void (location: RouteLocation): void (valid: false): void + (cb: (vm: any) => void): void } export interface NavigationGuard {