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
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-1b3ad02-2c270.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-1b3ad02-2c270.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?