[Vuex4] useStore

Rachaen·2023년 1월 28일
0

vue4 useStore

setup hook에서 store을 검색하기 위해서 useStore을 사용한다.

// Vuex version is 4.x
import { useStore } from 'vuex'

export default {
  setup () {
    const store = useStore()
  }
}

vue4 이전 store 검색

  1. this.storethis.store this.store.state.xxx
    this.store.commit(경로명/함수)this.store.commit('경로명/함수명') this.store.dispatch('경로명/함수명')
    this.$store.getters["경로명/함수명"];
  2. map
    mapState, mapMutation, mapActions, mapGetters

기존에는 $store가 global하게 있었지만 Vuex4에서는 global하지 않다.


Vue Use Utilities - Vuex/useStore

profile
개발을 잘하자!

0개의 댓글