0
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.

mapStateヘルパー

0
Posted at

mapStateヘルパー

this.$store.state.messageと書くのは少し長くて面倒なので、
ヘルパー関数が用意されています。

App.vueのスクリプトの部分を以下のように書き換えます。

App.vue
<script>
import { mapState } from 'vuex';

export default {
  computed: {
    message () {
      return this.$store.state.message;
    }
    ...mapState({
      message: 'message'
    })
  }
};
</script>

'message'というように文字列を渡すと内部的にはstate.messageと同じ扱いになります。

0
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
0
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?