programing

Vuex 알 수 없는 작업 유형...동작이 로딩되지 않음

prostudy 2022. 7. 29. 22:12
반응형

Vuex 알 수 없는 작업 유형...동작이 로딩되지 않음

알 수 없는 작업 유형에 문제가 있습니다.

store.syslog:

import Vue from 'vue'
import Vuex from 'vuex'
import { state } from './store/state'
import { mutations } from './store/mutations'
import { actions } from './store/actions'
import { getters } from './store/getters'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  actions,
  mutations,
  getters,
  state,
  plugins: [createPersistedState()]
})

actions.syslog

import { ServerAPI } from '../plugins/server-api'
import { Mutations } from './mutations'

export const Actions = {
  checkAuth: 'checkAuth',
  loadCustomers: 'loadCustomers'
}
export const actions = {
  [Actions.checkAuth] (context, payload) {
  },
  [Actions.loadCustomers] ({ commit }) {
    // context.state
    let customers = {}
    ServerAPI.getCustomers().then((response) => {
      if (response.status === 200) {
        response.data.forEach((customer) => {
          customers[customer.id] = customer
        })
        commit(Mutations.assignBulkCustomers, customers)
      }
    }).catch((error) => {
      console.log(error)
    })
    return Promise.resolve(customers)
  }
}

App.vue

methods: {
      ...mapActions([
        Actions.loadCustomers,
        Actions.checkAuth
      ]),

그리고 그것을 호출한다.

 this.loadCustomers()

나는 왠지 이 오류를 가지고 있다. [vuex] unknown action type: loadCustomers

디버깅 정보를 보면 액션이 로드되어 있지 않지만 getters와 mutrate는 로드되어 있는 것을 알 수 있습니다.

언급URL : https://stackoverflow.com/questions/56311497/vuex-unknown-action-type-wont-load-my-actions

반응형