vue中$store的用法

Store就是把它们联系到一起的对象。Store有以下职责:

  • 维持应用的state:
  • 提供getState( )方法获取state;
  • 提供dispatch(action)方法更新state;
  • 通过subscribe(listener)注册监听器;
  • 通过subscribe(listener)返回的函数注销监听器

前台搭配mapGetter使用,引入后,放在computed中

  •   import { mapGetters } from 'vuex';
  • computed: {
    ...mapGetters([
    'getLogin',
    'getuname',
    'getpwd'
    ])
    },

posted on 2018-09-14 14:27  Schon_zh  阅读(4445)  评论(0)    收藏  举报

导航