0👍
You can use the beforeRouteUpdate
in-component guard:
beforeRouteUpdate: (to, from, next) {
next(store.getters['ants/filter'](to.params.filter))
}
- [Vuejs]-How to accept multiple file types in swal sweetalert
- [Vuejs]-Excluding Resuable global components from another component
0👍
An alternate way would be to use this:
Note: Put this code on the same level as created: { }
, methods: { }
etc
watch: {
'$route' (to, from) {
// Your code.
}
}
Route guards are better but if you’re finding you need to use lots of them and call the same code then this could work instead as it reacts to any route changes.
Source:stackexchange.com