programing

이 $store 함수가 정의되지 않음

prostudy 2022. 4. 12. 22:34
반응형

이 $store 함수가 정의되지 않음

vuex의 저장소를 사용하여 API 호출을 수행하려고 하지만 vuex를 설치한 후 저장소를 파일로 가져오고 "vuex"로 내 저장소 파일을 내보내는 경우 vuex가 설치되었는지 확인하는 것과 같은 다른 스택 오버플로 응답을 따르십시오.Store" 등이 있지만 loadCalls 기능은 여전히 작동하지 않는다.

이것이 내가 얻는 오류다:

this.$store.loadCalls is not a function

여기 내 기능과 내가 그것을 어떻게 부르려고 하는지가 있다. 그것은 내 스토어 js 파일의 내 행동 섹션에 선언되어 있다.

loadCalls() {
   axios
        .get("/some/calls")
        .then(res => {
          console.log(res)
        });
},

나는 그것을 내 안에 사용해 본다.beforeMount()구성 요소가 로드될 때:

beforeMount(){
    this.$store.loadCalls();
}

내가 여기서 뭘 잘못하고 있는 거지?

다음과 같은 작업을 정의한 경우:

actions: {
  loadCalls() {
    // ...
  }
}

그러면 이렇게 부르겠지.

this.$store.dispatch('loadCalls');

동작이 직접 노출되지 않고 다음을 사용하여 호출dispatch.

https://vuex.vuejs.org/guide/actions.html#dispatching-actions

참조URL: https://stackoverflow.com/questions/56704246/thisstore-function-is-undefined

반응형