如何在Vuex中获取Vue路由器参数?

Sha*_*rix 6 vue.js vue-router vuex

我无法使用

this.$route.params
route.params
router.params
Run Code Online (Sandbox Code Playgroud)

如何在操作中获得$ route的参数?

小智 8

在您的actions.js或store.js中

import router from 'path/to/router'
console.log(router.currentRoute.params)
Run Code Online (Sandbox Code Playgroud)