반응형
Vue.js 2/Vuex - mapGetters를 사용하지 않고 true를 실행한 모듈에서 getter를 호출하는 방법
이 모듈은 다음과 같습니다.
const ModuleA={
namespaced:true,
state:{
categoryList:[
{name:'all', isActive:true},
{name:'negotiation', isActive:false},
]
},
getters:{
getCategory:(state)=>(index)=>{
return state.categoryList[index];
},
}
}
없이.namespaced:true
, 전화할 수 있습니다.getCategory
와 함께this.$store.getters.getCategory(this.index)
.
전화 방법getCategory
와 함께namespaced:true
사용할 수 없습니다.mapGetters
왜냐하면 나는 함수에 파라미터를 전달해야 하기 때문이다.
Vuex 모듈 게터 및 돌연변이에 액세스하는 방법에 대한 두 번째 답변을 참조하십시오.
this.$store.getters['ModuleA/getCategory'](this.index)
언급URL : https://stackoverflow.com/questions/47327388/vue-js-2-vuex-how-to-call-getters-from-modules-that-has-attribute-namespacedt
반응형
'sourcecode' 카테고리의 다른 글
인터뷰 질문:한 문자열이 다른 문자열의 회전인지 확인합니다. (0) | 2022.08.12 |
---|---|
Vue.js 2 - 하나의 애플리케이션/인스턴스 Vue에서 다른 애플리케이션/인스턴스 Vue로 $emit 이벤트를 발생시키는 방법 (0) | 2022.08.12 |
문자열 리터럴로 초기화되었지만 "char s[]"가 아닌 "char *s"에 쓸 때 세그멘테이션 장애가 발생하는 이유는 무엇입니까? (0) | 2022.08.12 |
GUI 애플리케이션용 크로스 플랫폼 C 라이브러리 (0) | 2022.08.12 |
what is Segmentation fault (core dumped)? (0) | 2022.08.12 |