I'm not able to use
this.$route.params
route.params
router.params
how do I get the params of $route in my actions?
You can access the current route through the state or rootState with Vuex.
If the action is in a module, use rootState:
MY_ACTION: ({rootState}) => new Promise((resolve, reject) => {
let params = rootState.route.params
// do stuff
}
If the action is not in a module, use state:
MY_ACTION: ({state}) => new Promise((resolve, reject) => {
let params = state.route.params
// do stuff
}
See https://vuex.vuejs.org/api/#actions for more information on the context object.
this.$store.dispatch('whatever', {route: this.$route})
– Christophe