"Vuex mapMutations"의 두 판 사이의 차이

(새 문서: ==개요== ;Vuex mapMutations * "컴포넌트 안에서 변이 커밋하기" * <code>this.$store.commit('xxx')</code>를 사용하여 컴포넌트에서 변이를 수행하거나 컴...)
 
11번째 줄: 11번째 줄:
   methods: {
   methods: {
     ...mapMutations([
     ...mapMutations([
       'increment' // this.increment()를 this.$store.commit('increment')에 매핑합니다.
       'increment' // this.increment()를 this.$store.commit('increment')에 매핑한다.
     ]),
     ]),
     ...mapMutations({
     ...mapMutations({
       add: 'increment' // this.add()를 this.$store.commit('increment')에 매핑합니다.
       add: 'increment' // this.add()를 this.$store.commit('increment')에 매핑한다.
     })
     })
   }
   }

2020년 9월 28일 (월) 16:32 판

1 개요

Vuex mapMutations
  • "컴포넌트 안에서 변이 커밋하기"
  • this.$store.commit('xxx')를 사용하여 컴포넌트에서 변이를 수행하거나 컴포넌트 메소드를 store.commit 호출에 매핑하는 헬퍼 (단, 루트 store 주입 필요)
import { mapMutations } from 'vuex'

export default {
  // ...
  methods: {
    ...mapMutations([
      'increment' // this.increment()를 this.$store.commit('increment')에 매핑한다.
    ]),
    ...mapMutations({
      add: 'increment' // this.add()를 this.$store.commit('increment')에 매핑한다.
    })
  }
}

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}