Vuex Tutorial #6 - Mutations > JS프레임워크

JS프레임워크

Vuex Tutorial #6 - Mutations 정보

Vue Vuex Tutorial #6 - Mutations

본문

Mutations https://vuex.vuejs.org/kr/guide/mutations.html

 

차일드에서 처리 할수 있지만

this.$store.state.products.forEach( product => {

  product.price -= 1;

})

 

코드가 많아지면 어디서 바꾸는지 트랙킹하기 힘들어짐.

 

mutations: {

  reducePrice: state => {

    state.products.forEach( product => {

      product.price -= 1;

    })

  }

}

 

this.$store.commit('reducePrice');

 

vue-devtools에서 트랙킹이 가능함.

 

store안에 strict : true로 하면 아웃사이드에서 수정불가 (에러남.)

 

https://github.com/iamshaunjp/vuex-playlist/tree/lesson-06

 

추천
0
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로