programing

Vuex에서 namesthed mapGetter의 이름을 변경하는 방법

prostudy 2022. 6. 3. 22:32
반응형

Vuex에서 namesthed mapGetter의 이름을 변경하는 방법

인마이nuxt사용하려는 프로젝트mapGettersrename object 구문을 사용합니다(문서 참조).getters는 모듈 내에서 네임슬레이징됩니다.currentTournament.

다음은 믹스인 내에서 계산된 속성입니다.

computed: {
  ...mapGetters('currentTournament', [{ tAllowedBaskets: 'allowedBaskets' }]),
}

컴포넌트를 로그에 기록하면this, 대신tAllowedBaskets새 속성이 나타나는 속성[object Object]: undefined단, 'simple' 문자열 구문을 사용하는 경우:

...mapGetters('currentTournament', ['allowedBaskets'])

allowedBaskets속성이 올바르게 표시됩니다.

오브젝트 구문이 작동하지 않는 이유는 무엇입니까?

적절한 구문은 다음과 같습니다.

...mapGetters('currentTournament', { tAllowedBaskets: 'allowedBaskets' }),

대괄호는 필요 없습니다.[]vuex 설명서의 이 부분에 나와 있는 바와 같이

언급URL : https://stackoverflow.com/questions/69076488/how-to-rename-a-namespaced-mapgetter-in-vuex

반응형