반응형
mapGetters에서 단일 Vue getter 별칭
나는 게터들이 있는 vuex 모듈을 가지고 있다.이 모듈의 게터를 vue 구성 요소에 사용하고 있다.
...
computed: {
...mapGetters('myCoolModule', ['isActive', 'someOtherGetter', 'yetAnotherGetter']),
}
...
나는 다른 vuex 모듈들을 가지고 있다.isActive
게터, 그래서 여기에 가명을 붙이고 싶어나는 객체 구문에 익숙하다.
...
computed: {
...mapGetters('myCoolModule', { myCoolModuleIsActive: 'isActive', someOtherGetter: 'someOtherGetter', yetAnotherGetter: 'yetAnotherGetter' }),
}
...
하지만, 나는 가명을 쓸 필요가 없다.'someOtherGetter'
또는'yetAnotherGetter'
, 그리고 객체 구문에서는 내가 단지 그것만을 해야 한다고 요구하는 것 같다.
getter 중 하나만 별칭으로 지정할 수 있도록 mapGetter와 함께 사용할 구문이 있는가?
두 번 사용하는 건 어때?
computed:
{
...mapGetters('myModule', {
myCoolModuleIsActive: 'isActive',
}),
...mapGetters('myModule', ['someOtherGetter', 'yetAnotherGetter']),
}
그리고 Vuex 모듈의 이름을 지정하는 것은 어떨까?따라서 이와 같은 이름의 충돌은 피할 것이다.
참조URL: https://stackoverflow.com/questions/62154946/alias-a-single-vue-getter-in-mapgetters
반응형
'Programing' 카테고리의 다른 글
공유 개체(.so), 정적 라이브러리(.a) 및 DLL(.so) 간의 차이점? (0) | 2022.04.22 |
---|---|
Vue CLI 쿠키 업데이트 또는 스토어 업데이트? (0) | 2022.04.22 |
JLabel의 배경색 설정 방법 (0) | 2022.04.21 |
vue/vuex 반응도 제한 (0) | 2022.04.21 |
gwt 컴파일러의 속도를 높이려면 어떻게 해야 하는가? (0) | 2022.04.21 |