Vue-router: beforeRouteEnter & beforeRouteLeave not working when route component created with Vue.extend

Created on 21 Oct 2016  路  12Comments  路  Source: vuejs/vue-router

beforeRouteEnter and beforeRouteLeave event not triggered when the route component is created using Vue.extend.

See: https://jsfiddle.net/budiadiono/76sgL1ee/4/

2.x bug

Most helpful comment

fixed in a5554a8

also, mixins usage are fixed in fb32ccb

All 12 comments

It seems assumes that extractEnterGuards plain options objects are used:

https://github.com/vuejs/vue-router/blob/dev/src/history/base.js#L167

Not working when defined in global mixins too.

@victorwpbastos +1

+1

I believe it doesn't work in Single File Component eigther.

I believe it doesn't work in Single File Component eigther.

That would be odd, as SFCs generally export simple options objects (which do work).

Any reproduction available?

it works in single file component, but only if hook is defined inside component itself, otherwise not working for ex. if defined in mixin or in extended component its not working.

fixed in a5554a8

also, mixins usage are fixed in fb32ccb

@sagarrabadiya beforeRouteUpdate doesn't work in Single file component
vue 2.2
vue-router 2.3.0

Please don't re-use 4 months old, closed issues.

I'm having this issue as well.
vue 2.5.4
vue-router 3.0.1

No matter what I do, beforeRouteUpdate never gets called. In my case I'm using the webpack loader setup.

Locking this issue since my first request obviously wasn't dead

Was this page helpful?
0 / 5 - 0 ratings