Closed
Description
Vue.js / vue-router versions
2.2.2 / 2.2.0
I have some subroutes in my app and want to watch for route changes in the parent. I use the beforeRouteUpdate
-hook. I have a created
-hook in the same Component. In a special state the app uses this.$router.push(...)
in the created hook, but that throws an Error.
Vue warn]: Error in created hook:
(found in <App> at E:\Work\vue\src\App.vue)
warn @ vue.esm.js?65d7:558
handleError @ vue.esm.js?65d7:1443
...
TypeError: Cannot read property 'foo' of undefined
at beforeRouteUpdate (eval at <anonymous> (app.js:795), <anonymous>:7:21)
at boundRouteGuard (eval at <anonymous> (app.js:876), <anonymous>:1751:18)
I access this.foo
in my beforeRouteUpdate
-hook and it works fine but not if there is a redirect in the created hook.
I can have access to this
in created()
, but not in beforeRouteUpdate()
, is this expected?
Here is a repo that reproduces when you open the app and reload the page:
https://github.com/ChrisGitter/vue-router-beforeRouteUpdate/