November 2017
Beginner to intermediate
398 pages
8h 42m
English
Getters work like computed properties for the store. They are functions that take the state and the getters as arguments, and return some state data:
const store = new Vuex.Store({ // ... getters: { user: state => state.user, }, })
user () { return this.$store.getters.user },
This doesn't seem to be different from before. But accessing the state directly isn't recommended--you should always use getters since it allows you to modify the way you get the data without having to change the components using it. For example, you can change the structure ...
Read now
Unlock full access