只是执行了一次push,为何会向数组里push两条相同的数据呢。
百思不得其解。
(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 只会做赋值操作
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 || {}, }; } },
慕莱坞森
相关分类