IT이야기

vuex 알 수 없는 작업 유형: showRegisterLogin/show

cyworld 2022. 5. 26. 23:07
반응형

vuex 알 수 없는 작업 유형: showRegisterLogin/show

내가 다음 코드를 썼는데 오류가 보인다.왜 이러는 거지?

오류

[vuex] 알 수 없는 작업 유형: showRegisterLogin/show

홈 페이지.부에를 하다 // 구성요소

sh 메서드를 사용할 때 이 오류가 발생함

import { mapState, mapActions } from "vuex";
export default {
  name: "HomePage",
  components: {
    RegisterLogin
  },

  data() {
    return {}
  },

  computed: {
    ...mapState({
      showRegisterLogin: state => state.showRegisterLogin.show
    }),
  },

  methods: {
    sh() {
      this.$store.dispatch('showRegisterLogin/show');
    }
  }
}

/ 저장 / 모듈 / showRegisterLogin.js

// States
const state = {
    show: false,
};

// Getters
const getter = {
    show (state) {
        return state.show;
    }
};

// Mutations
const mutation = {
    showPage (state) {
        return state.show = true;
    },
    hidePage (state) {
        return state.show = false;
    }
};

// Actions
const action = {
    show({ commit }) {
        commit('showPage');
    },
    hide({ commit }) {
        commit('hidePage');
    }
};

export default {
    namespaced: true,
    state,
    getter,
    mutation,
    action
}

/ store / store.js

'use strict';

import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

import showRegisterLogin from "./modules/showRegisterLogin";

export default new Vuex.Store({
    modules: {
        showRegisterLogin,
    }
});

store.js 파일도 app.js로 가져와서 새로운 vue에 등록했다.

모듈에 있는 저장소 개체의 이름을 제외하고 저장소, 모듈 및 구성 요소의 구조는 양호함:

  • getter그래야 한다getters

  • mutation그래야 한다mutations

  • action그래야 한다actions

아마 그냥 오자일 거야.그것은 Vuex가 특별히 그 열쇠들을 찾기 때문에 임의로 이름을 지을 수 없다.

참조URL: https://stackoverflow.com/questions/60858482/vuex-unknown-action-type-showregisterlogin-show

반응형