반응형
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
반응형
'IT이야기' 카테고리의 다른 글
플랫폼에서 "긴"과 "int"의 크기가 동일하다면 - "긴"과 "int"는 어떤 면에서 다른가? (0) | 2022.05.26 |
---|---|
명시적으로 선언되지 않은 Vue 소품 (0) | 2022.05.26 |
C에서 실행 파일의 위치를 찾으려면 어떻게 해야 하는가? (0) | 2022.05.25 |
If/Else If가 아닌 전환/대소문자를 바꾸는 이유 (0) | 2022.05.25 |
정적 코드 분석 도구 선택 (0) | 2022.05.25 |