Answer the question
In order to leave comments, you need to log in
How to track the change of an object in Vuex.store in Vue?
Hello. With Vue the second day is familiar. Before that, there was experience in developing SPA on Angular 1.6.
Now I'm trying to build the architecture right away correctly, using Vuex, because there will be a big SPA. And here is such a plug I have.
It is necessary to display several links in the menu only to an authorized user.
This is how I build the store and add it to the menu component: https://gist.github.com/yarkovaleksei/a09521de1a11...
Based on https://github.com/vuejs/vuex/blob/dev/examples/todomvc
Now if you write in the template like this: (pug)
md-list-item(v-if='session && session.id')
//-отображать меню
md-list-item(v-if='getSession() && getSession().id')
//-отображать меню
Answer the question
In order to leave comments, you need to log in
You can use mapState or mapGetters to pass values from the store, so there will be a minimum of glue code, i.e. in your case in the component you can write:
import {mapState} from 'vuex'
...
computed: {
...mapState(['session'])
}
md-list-item(v-if='session && session.id')
Start from this https://github.com/codecasts/spa-starter-kit
Check out this course https://coursehunters.net/course/udemy-vuejs-2
I was in your position, build from spa-starter-kit . I'm currently rewatching some of the videos.
The dock for vue, vue router and vuex is also constantly open.
As a result, I generally abandoned all spa starters and other "todos" in favor of
Yes, I do not give you a direct answer to your question, only advice on how not to step on the rake that I stepped on.
Watching your code by reference, you are laying down an architecture that is inconvenient for scaling in advance.
Take a closer look at localforage as a replacement for localStorage, even if you only need localStorage.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question