programing

스토어 변환 내에서 vuex "state property is read only"를 해결하는 방법

prostudy 2022. 7. 6. 20:42
반응형

스토어 변환 내에서 vuex "state property is read only"를 해결하는 방법

변환을 커밋하는 vuex 액션이 있습니다.

updateStateProperty: (state, payload) => {
  state.parent.child = payload.changer
}

그러면 다음이 출력됩니다.

TypeError: "자녀"는 읽기 전용입니다.

이 솔루션 예는 봤지만 deepClone 용도의 설명이 누락되어 있습니다.

[types.SET_FIELD] (state, payload) {
  let parent = deepClone(state.parent)
  parent.child = payload.changer

  state.parent = parent
}

다른 것도 봤지만 명확한 코드 예는 없었다.이 물건의 변경은 어떻게 하면 좋을까요?

언급URL : https://stackoverflow.com/questions/58673243/how-to-overcome-vuex-state-property-is-read-only-within-a-store-mutation

반응형