S
S
Sergey Sokolov2019-02-12 22:53:30
Vue.js
Sergey Sokolov, 2019-02-12 22:53:30

How to respond to parameter changes in the vuex store in vue-router?

In store I keep the parameter isLogged(true/false), which means whether the user is logged in.
Its state can change from several places: both by the "Exit" button, and by the server's response to the next request, and by timeout.
How best to do so that when the state changes to "logged out", the user is redirected to a specific route?
As far as I understand, shove into store.mutationssomething besides changing the store is not kosher. So how to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Romanov, 2019-02-12
@Djaler

There is no way to do this in the router itself. You have some main component that contains a router inside. Here in this component and monitor the state of this parameter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question