lesson 214: vuex actions
This commit is contained in:
parent
cdb9316050
commit
391303bad8
|
@ -23,7 +23,7 @@ export default {
|
|||
|
||||
methods: {
|
||||
increaseCounter() {
|
||||
this.$store.commit('increase', { value: 10 });
|
||||
this.$store.dispatch('increase', { value: 10 });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
export default {
|
||||
methods: {
|
||||
addOne() {
|
||||
this.$store.commit('increment');
|
||||
this.$store.dispatch('increment');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -28,6 +28,18 @@ const store = createStore({
|
|||
}
|
||||
return finalCounter;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
increment(context) {
|
||||
setTimeout(function() {
|
||||
context.commit('increment');
|
||||
}, 2000);
|
||||
},
|
||||
increase(context, payload) {
|
||||
setTimeout(function() {
|
||||
context.commit('increase', payload);
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Reference in New Issue