반응형
Vuex: 상태가 업데이트되지만 계산된 속성이 업데이트되지 않음
스토어에서 '엔드포인트'라는 속성을 가져와 약간 조정하는 컴포넌트가 있습니다.
computed: {
...mapState(['endpoints']),
adjustedEndpoints () {
if (this.endpoints){
return this.endpoints.map(x => {
x.displayName = x.name;
return x;
})
}
},
...템플릿의 테이블컴포넌트에 전달합니다.
<b-table show-empty
stacked="md"
:items="adjustedEndpoints"
:fields="fields"
:current-page="currentPage"
:per-page="perPage"
:filter="filter"
:sort-by.sync="sortBy"
:sort-desc.sync="sortDesc"
:sort-direction="sortDirection"
@filtered="onFiltered"
>
문제는 끝점의 속성을 편집할 때 Vue 구성 요소 상태에서 변경되지만 다시 로드될 때까지 렌더링된 구성 요소에 반영되지 않는다는 것입니다.adjusted Endpoints() 함수는 자동으로 호출되지 않을 것으로 예상됩니다.
어떻게 하면 고칠 수 있을까요?
문제를 발견했다.
Vuex 스토어의 초기 상태에서는 '엔드포인트' 속성을 선언하지 않았습니다.
그게 문제였어.
언급URL : https://stackoverflow.com/questions/50701670/vuex-state-updates-but-computed-property-doesnt
반응형
'programing' 카테고리의 다른 글
VueJs - 데이터 변경 시 아래로 스크롤하는 방법 (0) | 2022.07.28 |
---|---|
VueJS 구성 요소에서 중복 이벤트를 내보냅니다. (0) | 2022.07.28 |
이중성(예: Double Star(예:NSERror **? (0) | 2022.07.28 |
Vue JS의 확인란에 대한 적절한 양방향 바인딩 (0) | 2022.07.28 |
반복자를 목록으로 변환 (0) | 2022.07.28 |