반응형
Vue.js vuex 모듈 내보내기/가져오기 실패
Vuex 모듈을 사용하려고 합니다만, 정상적으로 동작하고 있지 않습니다.디스패치하려고 하는 기존의 조작이 표시됩니다.
store/index.displaces
import Vue from 'vue'
import Vuex from 'vuex'
import * as getters from '@/store/getters'
import { state, actions, mutations } from '@/store/root'
import authentication from '@/store/modules/authentication'
Vue.use(Vuex)
const store = new Vuex.Store({
strict: process.env.NODE_ENV !== 'production',
state,
actions,
mutations,
getters,
modules: {
authentication
}
})
export default store
store/displicate/authentication을 실행합니다.js
import * as types from '@/store/mutation_types'
import firebase from 'firebase'
const authentication = {
namespaced: true,
state: {
user: JSON.parse(localStorage.getItem('user')) || null,
account: JSON.parse(localStorage.getItem('account')) || null
},
actions: {
signUserUp ({commit}, payload) {
...
},
signUserIn ({commit}, payload) {
...
},
setUser ({commit}, newUser) {
console.log('STORE ACTION setUser: ', newUser)
commit(types.SET_USER, newUser)
},
setAccount ({commit}, newAccount) {
...
},
logout: context => {
...
},
mutations: {
...
}
}
export default authentication
main.discloss.main.discloss.
store.dispatch('setUser', null) // <== [vuex] unknown action type: setUser
모듈 선언에 문제가 있습니까?
사용하고 있다namespaced
module, 액션명에 네임스페이스를 포함해야 합니다.
store.dispatch('authentication/setUser', {});
더
다른 이름 지정 모듈에서 액션을 디스패치하는 경우{root: true}
파라미터:
dispatch('authentication/users', {}, { root: true });
언급URL : https://stackoverflow.com/questions/51346178/vue-js-export-import-vuex-module-failing
반응형
'itsource' 카테고리의 다른 글
C의 함수의 크기가 항상 1바이트인 이유는 무엇입니까? (0) | 2022.08.17 |
---|---|
너비가 다른 임의의 수의 요소를 래핑을 사용하여 그리드에 정렬 (0) | 2022.08.17 |
Java에서 개체 배열을 문자열 배열로 변환하는 방법 (0) | 2022.08.16 |
Vue에서 구성 요소가 생성되었을 때 기능을 구현하는 방법은 무엇입니까? (0) | 2022.08.16 |
2차원 어레이를 할당하는 이상한 방법? (0) | 2022.08.16 |