vue.js, nuxt.js mapActions

acctto·2022년 4월 11일
0

vue.js/nuxt.js 에서 mapActios를 사용할 때마다 항상 헷갈려서 간단하게 기록해 둔다.

ex) nuxt.js

  • page/user.vue
<script>
  import { mapActions } from "vuex";
  
  export default {
    data() {
      return {
        users: [],
      }
    },
    methods: {
      ...mapActions("user", ["getUserList"]), // module, ['action name']
    },
    async created() {
      this.users = await this.getUserList();
      // this.users = this.$store.dispatch("user/getUserList");
    },
  }
  
</script>
profile
Nice

0개의 댓글