반응형
계산된 속성 내에서 getter를 호출하는 방법
의 모듈 모드를 사용하고 있습니다.store
그리고 내 안에projects.js
스토어 폴더 내에는 다음과 같은 것이 있습니다.
export const getters = {
loadedProjects(state) {
return state.loadedProjects;
}
}
내 계산으로는 뭐라고 불러야 할까?난 그렇게 노력하고 있어.
computed: {
loadedProjects() {
return this.$store.getters.projects.loadedProjects;
},
}
하지만 다음 오류가 나타납니다.
Cannot read property ‘loadedProjects’ of undefined
같은 문제가 있었습니다.모듈 모드를 사용하고 있는 경우는, 다음과 같이 getter를 호출할 수 있습니다(고객의 경우). this.$store.getters['projects/loadedProjects'];
따라서 다음과 같이 컴퓨터를 변경해 보십시오.
computed: {
loadedProjects() {
return this.$store.getters['projects/loadedProjects'];
},
}
이렇게 불러야 합니다.
loadedProjects() {
return this.$store.getters['projects/loadedProjects'];
}
$store.getters['moduleName/getterName']
언급URL : https://stackoverflow.com/questions/57791973/how-to-call-a-getter-inside-a-computed-properties
반응형
'programing' 카테고리의 다른 글
마운트된 후크에서 VueTable 2 $refs 개체가 비어 있습니다. (0) | 2022.08.11 |
---|---|
Vue.js는 여러 클릭 이벤트를 처리합니다. (0) | 2022.08.11 |
Nuxt.js: vuex에서 표시기 로드 시작 (0) | 2022.08.11 |
다음 오류가 nuxt에 표시됨: [vuex] 변환 핸들러 외부의 vuex 저장소 상태를 변환하지 않음 (0) | 2022.08.11 |
주요 메서드 Java의 "String args[]" 매개 변수란 무엇입니까? (0) | 2022.08.11 |