Counter.js 335 B

1234567891011121314151617181920212223242526
  1. const state = {
  2. main: 0
  3. }
  4. const mutations = {
  5. DECREMENT_MAIN_COUNTER (state) {
  6. state.main--
  7. },
  8. INCREMENT_MAIN_COUNTER (state) {
  9. state.main++
  10. }
  11. }
  12. const actions = {
  13. someAsyncTask ({ commit }) {
  14. // do something async
  15. commit('INCREMENT_MAIN_COUNTER')
  16. }
  17. }
  18. export default {
  19. state,
  20. mutations,
  21. actions
  22. }