Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Vue Router Params in Vuex?

I'm not able to use

this.$route.params
route.params
router.params

how do I get the params of $route in my actions?

like image 491
Philipp Mochine Avatar asked Jun 12 '18 19:06

Philipp Mochine


People also ask

How can I get route ID in Vuejs?

to get the value of the id route parameter with this. $route.params.id with the options API. We call useRoute to return the route object and then we get the value of the id route parameter with route.params.id .

How do I watch my vue route?

To listen for route change events with Vue. js and Vue Router, we can watch the $route object in our component. to watch the $route in our component. We set deep to true to watch for all changes in the $route object's contents.


1 Answers

in your actions.js or store.js

import router from 'path/to/router'
console.log(router.currentRoute.params)
like image 154
d49tt0 Avatar answered Oct 29 '22 22:10

d49tt0