Getting router params into Vuex actions
To get params from vuex
store action, import your vue-router
's instance, then access params of the router instance from your vuex
store via the router.currentRoute
object.
Sample implementation below:
router at src/router/index.js
:
import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
Vue.use(VueRouter)
const router = new VueRouter({
mode: 'history',
routes
})
export default router
import the router at vuex store:
import router from '@/router'
then access params at vuex action function, in this case "id", like below:
router.currentRoute.params.id
Not sure to understand well your question, but :
This plugin keeps your router' state and your store in sync :
https://github.com/vuejs/vuex-router-sync
and it sounds like what you are looking for.