zoukankan      html  css  js  c++  java
  • vuex

    https://vuex.vuejs.org/zh-cn/api.html

    命令

    用途

    备注

    this.$store

    组件中访问store实例

     

    store.state.a

    获取在state对象中的数据

    store文件中

    $store.state.a

    视图上(即标签上)

     

     

    this.$store.state.a

    1) 组件内部,data数据里边

    2) 组件计算属性返回值

    computed: { 

       count () { return this.$store.state.count }

     }

     

    store.getters

    派生state的一些状态(即拿到,再进行一些小变化后返回新的状态,比如给state中某个数组内部小于10的前边加上0再返回)

    Getter对象

    this.$store.getters.oneFunction

    访问Getter对象内的某个属性的值

    在组件的计算属性中使用

    store.commit()

    【方法】提交 mutation,触发状态变更(修改state的值)

    action文件中

    this.$store.commit(state,payload)

    在组件的 methods 中

    store.dispatch()

    【方法】触发 action,以间接地触发mutation,进而使状态变更(修改state的值)

    action文件中

     

    this.$store.dispatch('incrementBy',amount)

    在组件的 methods 中

    'incrementBy':  mutationFunctionName

    amount =  payload

    2018-04-07  18:00:52

  • 相关阅读:
    视频解析小技巧
    linux系统路由设置
    tracert路由跟踪命令
    php+nginx
    docker快速拉取镜像
    linux命令
    添加docker命令
    linux模糊查询文件名
    查看日志
    模板函数与模板类
  • 原文地址:https://www.cnblogs.com/padding1015/p/8734041.html
Copyright © 2011-2022 走看看