반응형
vuex 계산 속성이 있는 vue가 업데이트되지 않음
저는 vuex와 socket.io 를 주에 사용하고 있습니다.Nodes.nodes 업데이트.단일 노드(인덱스 4)를 업데이트하고 있으며 setInterval을 사용하여 로깅할 때 정확히 동일한 output_state 및 계산된 속성(노드 4 output_state) - 변환 후 서로 다릅니다!
computed: {
tmpStatus () {
if (this.$store.state.Nodes.nodes.length !== 0) {
return this.$store.state.Nodes.nodes[4].output_state
} else {
return null
}
}
},
created () {
this.debugInterval = setInterval(() => {
console.log('Devicesstate', this.$store.state.Nodes.nodes[4].output_state, this.tmpStatus)
}, 2000)
},
돌연변이는 다음과 같은 방식으로 수행됩니다.
let nodeFound = state.nodes.filter(item => item.node_id === node.node_id)[0]
let nodeIndex = state.nodes.indexOf(nodeFound)
state.nodes[nodeIndex] = node
업데이트 전 결과(둘 다 동일): Devicesstate true true
업데이트 후 결과 - false로 변경(각각 다릅니다!): Devicesstate false true
변환을 이렇게 변경했습니다(Vue to file 가져오기).
Vue.set(state.nodes, nodeIndex, node)
그리고 그것은 동작한다.
변환을 이렇게 변경했습니다(Vue to file 가져오기).
Vue.set(state.nodes, nodeIndex, node)
그리고 그것은 동작한다.
언급URL : https://stackoverflow.com/questions/47387373/vue-with-vuex-computed-property-not-updating
반응형
'prosource' 카테고리의 다른 글
워드프레스 스테이징 환경 (0) | 2023.06.27 |
---|---|
C/C++(GCC/G++)을 사용하는 Linux의 소켓 프로그래밍에서 파일 보내기 및 받기 (0) | 2023.06.27 |
SQL 쿼리 결과를 csv 또는 Excel로 내보내는 중 (0) | 2023.06.27 |
Android:java.lang.Out Of Memory Error: OOM까지 2097152의 사용 가능한 바이트와 2MB를 포함하는 23970828바이트 할당에 실패했습니다. (0) | 2023.06.27 |
Oracle에서 Greatest 함수에 Null 처리 중 (0) | 2023.06.27 |