반응형
getter에서 Vue 체인 여러 필터
Getter에서는 배열을 필터링하여 2개의 조건에 일치하는 값을 반환해야 합니다.현재 위치와 동일한 item_category_location이 없거나 item_category_locations가 전혀 없는 item_category를 반환해야 합니다.
unaddedItemCategories(state, getters, rootState) {
let otherLocations = state.item_categories
.filter((item_category) =>
item_category.item_category_locations.some((item_category_location) => item_category_location.location_id !== rootState.currentLocation.id))
let noLocations = state.item_categories
.filter(item_category => item_category.item_category_locations.length == 0)
return otherLocations, noLocations
},
2개의 필터는 정상적으로 동작.새로운 어레이를 작성하려면 어떻게 해야 합니까?
다음과 같이 할 수 있습니다.
return [...otherLocations, ...noLocations]
언급URL : https://stackoverflow.com/questions/59609475/vue-chain-multiple-filters-in-getter
반응형
'programing' 카테고리의 다른 글
Spring Security 인증과 cookie의 교차 발신지 vs Authorization 헤더 (0) | 2022.08.11 |
---|---|
페이지 새로 고침 후 v-treeview 상태를 유지하는 방법 (0) | 2022.08.11 |
VueJ: 렌더링을 또는 (0) | 2022.08.11 |
최적화되지 않는 무한 빈 루프를 만들려면 어떻게 해야 합니까? (0) | 2022.08.11 |
vue 앱 새로 고침: GET /path를 가져올 수 없음 (0) | 2022.08.10 |