N
N
Nikita Reshetnyak2020-05-09 16:44:27
Vue.js
Nikita Reshetnyak, 2020-05-09 16:44:27

How to use store.action in router vuejs?

Good day. We need to make a state change in the vuex store using beforeEach/afterEach in the routes. I connected the storage itself to the routes file, I can easily get the state using store.getters.getterName, but you can’t call actions in the same way, logging store to the console showed that actions are available by name _actions. But it turns out that they cannot be called in such a way that the state in the repository changes. How can you call actions in routes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bubaley, 2020-05-09
@MeG1tsune

If you have included store in the router
How to import store from 'your path'
In order to call actions you need to use:
store.dispatch('event name')
By ​​analogy with the call in the vue application itself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question