반응형
Nuxt.js 스토어, 다른 스토어에 디스패치액션
내 Nuxt.js 앱에 2개의 스토어가 있는데 다른 스토어에 액션을 디스패치해야 합니다.
export const actions = {
addToCart({ state, commit, dispatch }) {
dispatch('CartLoadingStore/enableLoadingBar')
this.$axios
.post('something')
.then(response => {
(...)
dispatch('CartLoadingStore/disableLoadingBar')
})
},
}
다른 가게로 액션을 보낼 수 없을 것 같습니다.그래요?아니면 그렇게 하는 방법이 있나요?
위의 경우 다음 오류가 발생합니다.
[vuex] unknown local action type: CartLoadingStore/enableLoadingBar, global type: StoreTheActionDispatchedFrom/CartLoadingStore/enableLoadingBar
디스패치 콜에 루트 파라미터를 추가해야 합니다.
dispatch('CartLoadingStore/disableLoadingBar', null, { root: true })
여기 문서
언급URL : https://stackoverflow.com/questions/54280875/nuxt-js-store-dispatch-action-to-other-store
반응형
'programing' 카테고리의 다른 글
테일윈드 CSS에서 폭 전환은 어떻게 하나요? (0) | 2022.07.02 |
---|---|
Vee-validate 3.0에서 URL을 검증하는 방법 (0) | 2022.07.02 |
구성 [Spring-Boot]에서 '패키지' 유형의 빈을 정의하는 것을 검토하십시오. (0) | 2022.07.02 |
이거 보세요.$140입니다.set Timeout 푸시 (0) | 2022.07.02 |
vuex에서 getter의 특별한 용도는 무엇입니까? (0) | 2022.07.02 |