state.js
state:{
data:{}
}
mutation.js
type.data (state, arg) {
return state.data = arg
}
action.js
commit(types.data, {a: 111, b: 222})
getters.js
export const data = (state) => {
return state.data
}
is called in the methods method of the component, not in the template template.
this.$store.getters.data //{a:111, b:222}
this.$store.state.data //{a:111, b:222}
,.
this.$store.getters.data.a // undefined
this.$store.state.data.a // undefined