반응형
Vuex 변환: ES6 구문을 사용하여 상태 매개변수를 분해합니다(퀘이사 프레임워크 사용).
저는 두 개의 다른 구문을 가지고 있습니다.mapGetters() 및 mapActions()를 사용하여 getters 및 작업에 액세스할 수 있습니다.첫 번째 것은 상태 매개 변수를 분해하지 않고 작동합니다.두 번째는 상태를 분해하지만 돌연변이가 상태를 변형시키지 않는 반면, 게터는 상태에 접근할 수 있고 동작은 컨텍스트를 분해하는 데 문제가 없습니다.
나는 왜 그런지 이해하지 않아요.ES6 / vuejs / vuex / 퀘이사를 잘못 사용합니까?
Vue.use(Vuex)
export default new Vuex.Store({
state: {
counter1: 0,
counter2: 0
},
getters: {
counter1: state => state.counter1,
counter2: ({ counter2 }) => counter2
},
mutations: {
increment1: state => state.counter1++,
increment2: ({ counter2 }) => counter2++
},
actions: {
increment1: context => context.commit('increment1'),
increment2: ({ commit }) => commit('increment2')
}
})
내 친구가 답을 주었습니다.ES6를 잘못 사용했습니다.
counter2}이(가) state.counter2를 참조하지 않지만 복사본을 만듭니다.
counter2를 변경할 때 state.counter2를 변경할 수 없다는 것은 이해가 됩니다.
언급URL : https://stackoverflow.com/questions/52202628/vuex-mutation-deconstruct-state-parameter-using-es6-syntax-using-quasar-framew
반응형
'programing' 카테고리의 다른 글
| Meteor.js는 "example.com " 또는 "www.example.com "에 배포합니까? (0) | 2023.06.28 |
|---|---|
| 10진수에 대한 NLS_NUMERIC_CHARTS 설정 (0) | 2023.06.28 |
| Windows git "경고: LF가 CRLF로 대체됩니다", 이 경고 테일이 역방향입니까? (0) | 2023.06.28 |
| ASP.NET MVC 글로벌 변수 (0) | 2023.06.28 |
| gradle build와 gradle bootJar의 차이점은 무엇입니까? (0) | 2023.06.28 |