sourcecode

Vue.js 2/Vuex - mapGetters를 사용하지 않고 true를 실행한 모듈에서 getter를 호출하는 방법

copyscript 2022. 8. 12. 23:34
반응형

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

반응형