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

  • 相关阅读:
    PHP入门
    bootstrap框架
    jsp5 include forward param
    jsp4 Cookie
    网页定位导航
    jsp3 javabean
    Obsidian md安装闪退
    Excel 2016 Mac VBA 的变化 窗体消失
    Excel Mac 2016 调用 Applescript
    如何自学R
  • 原文地址:https://www.cnblogs.com/padding1015/p/8734041.html
Copyright © 2011-2022 走看看