码迷,mamicode.com
首页 > 其他好文 > 详细

vue中$store的用法

时间:2018-09-14 16:00:31      阅读:7011      评论:0      收藏:0      [点我收藏+]

标签:dispatch   name   tst   用法   list   getters   listener   通过   stat   

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

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

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

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

vue中$store的用法

标签:dispatch   name   tst   用法   list   getters   listener   通过   stat   

原文地址:https://www.cnblogs.com/schon/p/9646378.html

(2)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!