lesson 216: mapGetters

This commit is contained in:
Andreas Zweili 2021-05-04 22:56:35 +02:00
parent 391303bad8
commit 096fa93a5c
3 changed files with 9 additions and 11 deletions

View File

@ -1,14 +1,14 @@
<template>
<h3>{{ counter }}</h3>
<h3>{{ finalCounter }}</h3>
<p>More...</p>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
computed: {
counter() {
return this.$store.getters.normalizedCounter;
}
...mapGetters(['finalCounter'])
}
};
</script>

View File

@ -1,13 +1,13 @@
<template>
<h3>{{ counter }}</h3>
<h3>{{ finalCounter }}</h3>
</template>
<script>
import { mapGetters } from 'vuex';
export default {
computed: {
counter() {
return this.$store.getters.finalCounter;
}
...mapGetters(['finalCounter'])
}
};
</script>

View File

@ -36,9 +36,7 @@ const store = createStore({
}, 2000);
},
increase(context, payload) {
setTimeout(function() {
context.commit('increase', payload);
}, 2000);
context.commit('increase', payload);
}
}
});