반응형
vuex: 네임슬레이드모듈 내에서 콜 변환이 필요한 이유는 무엇입니까?
다음과 같은 vuex 구성을 가지고 있습니다.
import listing from '@/store/modules/listing'
var store = new Vuex.Store({
modules:
{
listing: listing,
},
리스트 모듈코드는 다음과 같습니다.
import Vue from 'vue'
const listing = {
namespaced: true,
state: {
listingAllItems: [],
listingSelectedItems: [],
},
mutations: {
updateListingAllItems(state, param) {
},
},
actions: {
getListingItems(context, param) {
var tempThis = this;
return new Promise((resolve, reject) => {
var url = 'http://WS/';
Vue.http.get(url).then(response => {
tempThis.commit('updateListingAllItems', response.data);
}).catch(error => reject(error));
})
},
},
getters: {}
}
export default listing
이 .commit ('updateListingAllItems', response.data)를 호출하면 알 수 없는 변환 유형 updateListingAllItems가 나타납니다.
Vuex 가이드에 따르면
이름 지정 게터 및 액션에는 현지화된 게터, 디스패치 및 커밋이 포함됩니다.즉, 같은 모듈에 프레픽스를 입력하지 않고 모듈애셋을 사용할 수 있습니다.
그러면 오류 메시지가 표시되는 이유는 무엇입니까?
액션 메서드 내부this
가게입니다.코드가 스토어 인스턴스에서 프리픽스되지 않은 변환을 커밋합니다.
바꾸면
tempThis.commit('updateListingAllItems', response.data);
로.
context.commit('updateListingAllItems', response.data);
기대했던 걸 얻을 수 있을 거야
언급URL : https://stackoverflow.com/questions/46738473/vuex-why-calling-mutation-from-within-a-namespaced-module-requires-a-prefix
반응형
'programing' 카테고리의 다른 글
아래 쿼리에서 테이블을 만드는 동안 오류가 발생했습니다. (0) | 2022.11.03 |
---|---|
사람이 읽을 수 있는 파일 크기 버전을 가져오시겠습니까? (0) | 2022.11.03 |
Mysql Server 5 vs 6 vs MariaDB (0) | 2022.11.03 |
나사산이 손실된 경우 테이블 잠금 해제 (0) | 2022.11.03 |
JSON을 Ordered Dict에 로드할 수 있습니까? (0) | 2022.11.03 |