The vuex mutations update data is written in spread (...). Why didn't the view update be triggered?

vuex

const list = {
  state: {
    list: []
  },
  mutations: {
    update: (state, e) => {
      for (let i = 0; i < state.list.length; iPP) {
        // 
        // state.list[i] = { ...e, ...state.list[i] }
        for (const ii in e) {
          state.list[i][ii] = e[ii]
        }
      }
    }
  }
}

export default list

state.list is originally an empty array, state.list [I] can assign values,
but if state.list [I] is empty, state.listi = e [ii] directly;
will not find the ii' attribute corresponding to state.list [I], state.list [I] has not been defined and its memory space has not been allocated.
should state.list [I] = {} first. Then assign the value, or directly use the subject state.list [I] = {... e,... state.list [I]} literally.


you use Vue.set (state.list,i, {... eMagne.state.list [I]}).

Menu