Vuex-状态的子属性是只读的,如何解决?

时间:2019-11-03 15:21:19

标签: vue.js

我有一个vuex动作会导致突变:

updateStateProperty: (state, payload) => {
  state.parent.child = payload.changer // trying to modify child property - fail
}

这抛出一个:

TypeError: ""child" is read-only"

我已经看到了此示例解决方案,但缺少有关deepClone目的的解释:

   setSomething(state, payload) {
      let parent = deepClone(state.parent) // what is deepClone here?
      parent.child = payload.changer

      state.parent = parent
    }

也看到了其他内容,但没有清晰的代码示例。我应该如何更改此属性?

0 个答案:

没有答案