The vuex value does not change after the asynchronous operation

initialize an object in state.

// 
travellerInfo: {
    after: {
        address: {},
        temporary: {
            people: {
                data: [],
                ids: [],
            },
            stroke: {
                data: {},
                complete: "",
            },
            take: {
                data: {},
                ids: {},
            },
            address: {
                data: {},
                ids: [],
            },
        },
        traveler: {},
    },
},


// 
commit("setTravellerInfo", this.state.travellerInfo);
setTravellerInfo(state, payload) {
    state.travellerInfo = payload;
},

when the data asynchronous request comes back, the data field in the vuex changes, but the ids field remains the same. The back-end interface has data.

/ / display of vue debugging tools
clipboard.png

// idsvuex

clipboard.png

May.20,2022

at least post the key code. It should be that you made a mistake in processing the data returned by the back end.


assignment problem, use your own code bug.
also recommend the merging method of lodash:

this.state.travellerInfo = _.merge({}, this.state.travellerInfo, res);
Menu