vuex 使用技巧

Author Avatar
Jzxer 6月 15, 2017
  • 在其它设备中阅读本文章

Action

提供方法和API请求,类似于mutation

mutation 修改 state 只能是同步的

  • action 充满了各种异步 api
    actions: {
      increment (context) {
          context.commit('increment')
     }
    }
    另一种写法
    increment({commit}) {
      commit('increment')
    }
    

分发 Action

store.dispatch(‘increment’)

转载请注明出处,谢谢!
本文链接:http://blog.jzxer.cn/vuex-模块介绍.html