반응형
Vuex Store getter 함수를 찾을 수 없습니다.
다음은 vuex 스토어에 있는 내 getters입니다.
const getters= {
getUser: (state:any) => {return state.user}
};
제 견해로는 다음과 같습니다.
<script lang="ts">
...
import {createNamespacedHelpers} from 'vuex'
const {mapMutations, mapGetters} = createNamespacedHelpers('user');
export default Vue.extend({
computed: {
...mapGetters([
'getUser'
])
},
methods: {
...mapMutations([
'change'
]),
login() {
this.change(email); //This is a function in the mutations. And this is working
this.loggedin = this.getUser(); // Here it says error
}
}
});
다음과 같은 에러가 표시됩니다.
TypeError: this.getUser is not a function콜this.change(email);하지만 변이 기능은 작동하고 있습니다.
computed속성 없음methods호출되지 않도록 하는 거죠동작은 마치setters그리고.getters
this.getUser는 계산 속성으로, 값 자체로서 동작합니다.당신은 그것을 다루려고 한다.method할 때()호출하도록 합니다.그건 불가능하죠. 왜냐하면 그건fn그래서 오류가 나타나는 거예요.
https://vuejs.org/v2/guide/computed.html#Computed-Caching-vs-Methods 를 참조해 주세요.
Vuex getters/states에 포함되다computedvue의 특성instances그들의 일 자체가 반환되는 것이기 때문에value.하지만mutations/actions안에 포함시키다methods하는 것이 본연의 임무인 재산perform조작 예 - 만들기async요구 및 갱신state
언급URL : https://stackoverflow.com/questions/59101916/vuex-store-getter-function-not-found
반응형
'programing' 카테고리의 다른 글
| V-Data-Table의 Select-All [VUETIFY]에서 비활성 항목 제외 (0) | 2022.07.27 |
|---|---|
| Laravel Mix: Node.js 의존관계 갱신 (0) | 2022.07.27 |
| 글로벌 확인 대화상자 기능 구현에 관한 Vuejs 문제 (0) | 2022.07.26 |
| Vuex 조건부(Lazy-loading) 스토어 (0) | 2022.07.26 |
| 프로그래밍 방식으로 마운트된 Vue 구성 요소에서 방출된 이벤트 듣기 (0) | 2022.07.26 |