lesson 216: mapGetters
This commit is contained in:
parent
391303bad8
commit
096fa93a5c
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -36,9 +36,7 @@ const store = createStore({
|
|||
}, 2000);
|
||||
},
|
||||
increase(context, payload) {
|
||||
setTimeout(function() {
|
||||
context.commit('increase', payload);
|
||||
}, 2000);
|
||||
context.commit('increase', payload);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Reference in New Issue