scrimba
Learn Vuex
Update state asynchronously with Vuex Actions
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Update state asynchronously with Vuex Actions
AboutCommentsNotes
Update state asynchronously with Vuex Actions
Expand for more info
index.js
run
preview
console
import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const store = new Vuex.Store({
state: {
count: 0
},
mutations: {
increment (state) {
state.count++
},
decrement (state) {
state.count--
}
},
actions: {

}
})

import { mapState, mapMutations } from 'vuex';

new Vue({
el: '#app',
store,
data: {
},
computed: mapState([ 'count' ]),
methods: {
increment () {
this.$store.commit('increment');
},
decrement () {
this.$store.commit('decrement');
},
}
});
Console
"Download the Vue Devtools extension for a better development experience: https://github.com/vuejs/vue-devtools"
,
"You are running Vue in development mode. Make sure to turn on production mode when deploying for production. See more tips at https://vuejs.org/guide/deployment.html"
,
index.html
-5:41