Using push in vuex to add data to an array will add two identical pieces of data

only executes push once, why push two identical data to the array.
I am puzzled.


(this.state.updateTripInfoObj.people.data).push(obj); // 
this.state.travellerInfo.after.temporary.people.data.push(obj);

commit("setTripInfoObj", {
    type: "people",
    res: this.state.updateTripInfoObj.people.data,
});
commit("setTravellerInfo", this.state.travellerInfo);

setTripInfoObj can only do assignment

setTripInfoObj(state, payload) {
    if (payload.type === "people") {
        state.updateTripInfoObj.people.data = payload.res;
    } else {
        const { address, people, stroke, take } = payload;
        state.updateTripInfoObj = {
            people: people || [],
            stroke: stroke || {},
            address: address || [],
            take: take || {},
        };
    }
},
May.20,2022

vuex emphasize:

the only way to change the state in the store of the Vuex is to submit the mutation.

do not modify the status directly on state . You first modify it manually, and then through mutation , which is not added twice.


you can learn from this simple example ide/" rel=" nofollow noreferrer "> https://vuex.vuejs.org/zh/guide/


it has been suspected that it is caused by data push.
provides two ideas:

1.:
2.commit
Menu