2
현재 웹 프로젝트에서 작업 중입니다. VueJS 2와 Vuex 2를 사용합니다. 문제점은 내 상태의 subArray를 업데이트 할 때 상태가 뷰에 바인딩되지 않는다는 것입니다.VueJS : Vuex가 상태를 수정 한 후에보기를 업데이트하지 않습니다.
내 주 :
export const state = {
comments: [],
}
돌연변이 :이 exemple에서
...
export const mutations = {
ADD_REPLY (state, { id, comment }) {
let c = state.comments.find((c) => c.id === step);
if (c.replies === undefined)
c.replies = [];
c.replies.push(comment);
}
}
...
, 내가 응답 (ADD_REPLY)를 누르면, 그것은보기에 업데이트 아니에요. 너는 어떤 생각을 가지고 있니?
을 사용하십시오. https://vuex.vuejs.org/en/mutations.html#mutations-follow-vues-reactivity-rules – Phil
@Phil 이것을 사용하려고했습니다. 'Vue.set (c. 답장, c.replies.length, comment);'그러나 작동하지 않습니다 –
아마도'c.replies = c.replies.concat (comment)'를 시도해보십시오. – Phil