반응형
다음 오류가 nuxt에 표시됨: [vuex] 변환 핸들러 외부의 vuex 저장소 상태를 변환하지 않음
저는 nuxt.dll을 사용하고 있는데 vuex에게 현재 곡 시간을 넘겨주고 싶어요.
단 한 번만 작동하면 데이터가 전달됩니다.
데이터는 다음과 같습니다.
currentSongTime: {
second: 0,
minute: 0,
total: 0
}
탑재:
this.WaveSurfer.on('seek', (position) => {
this.currentSongTime.second = parseInt(position * this.WaveSurfer.getDuration() % 60);
this.currentSongTime.minute = parseInt((this.WaveSurfer.getCurrentTime() / 60) % 60);
this.currentSongTime.total = parseInt(position * this.WaveSurfer.getDuration());
this.$store.commit('setCurrentSongTime', this.currentSongTime);
});
index.vuex:
export const state = () => ({
currentAudioTime: {}
});
export const mutations = {
setCurrentSongTime(state, val) {
state.currentAudioTime = val;
}
};
한 번만 작동하면 다음 오류 메시지가 나타납니다.
[vuex] do not mutate vuex store state outside mutation handlers.
어떻게 해야 할까요?
컴포넌트 데이터를 다음과 같이 직접 설정하고 있습니다.Vuex컴포넌트 데이터를 수정하면 변환 핸들러의 외부 상태도 직접 변환되기 때문에 문제가 발생합니다.빠른 수정은 이 개체를 할당하기 전에 복제하는 것입니다.vuex상태:
this.$store.commit('setCurrentSongTime', JSON.parse(JSON.stringify(this.currentSongTime)));
언급URL : https://stackoverflow.com/questions/55667142/getting-this-error-in-nuxt-vuex-do-not-mutate-vuex-store-state-outside-mutati
반응형
'programing' 카테고리의 다른 글
| 계산된 속성 내에서 getter를 호출하는 방법 (0) | 2022.08.11 |
|---|---|
| Nuxt.js: vuex에서 표시기 로드 시작 (0) | 2022.08.11 |
| 주요 메서드 Java의 "String args[]" 매개 변수란 무엇입니까? (0) | 2022.08.11 |
| 이것과의 차이점.$parent.$170이랑 이거요.$140 (0) | 2022.08.11 |
| vueJ에서 v-select v2.5.1에서 선택한 옵션의 ID를 바인딩하는 방법 (0) | 2022.08.11 |