3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vuexで名前空間(Namespace)を使う

3
Posted at

Namespace とは

このオプションを付けることで、state, getters, actions, mutationsには自動的に自分が属しているmodule名(この場合helloModule)と同名のnamespaceが付与されます

example.js

export default {
  namespaced: true, // 追加
  state: {
  },
  actions: {
    updateMessage(){
      // 処理
    }
  }

呼び出すときは「mapState/mapActionsに引数で名前空間を渡す」「名前空間を明示的に指定する」のどちらのパターンでもOK。

example.vue

methods: {
  update() {
    this.$store.dispatch('example/updateMessage');
  },
}

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?