Vuex calls this.$store.state.xx.xx undefind in the component

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

Please tell me how to call ~ directly in the component?

Nov.01,2021

landlord, you can refer to this article, Portal

. < hr >

here is the code for my local test, and the conclusion is that it is all values that can be taken

.

/ / vuex related
/ / store.js


state.js
state: {
   remind: {}
}

mutation_types.js
export const REMAIND = 'REMAIND'

mutation.js
[type.REMIND] (state, arg) {
    state.remind = arg
}

actions.js
getdata ({state, commit}, arg) {
    ...,
    commit(types.REMAIND, {free: res.data.freeNum, queue: res.data.queueNum})
}


getters.js
export const remind = (state) => {
    return state.remind
}

test.vue
methods:{
   submit () {
       this.$store.dispatch('getData')
       console.log(this.$store.getters.remind)       // {obj....arry(0)}
       console.log(this.$store.getters.remind.free)   // undefined
       console.log(this.$store.getters.remind.queue)  // undefined
   }
}
the first click on submit is empty
the second click on submit is worth it.
both state, and getters are like this. Why?
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4c95d-44ee2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4c95d-44ee2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?