Skip to content

Instantly share code, notes, and snippets.

@oomusou
Created September 25, 2018 06:40
Show Gist options
  • Save oomusou/f84b670292c2c34df701076300b442a9 to your computer and use it in GitHub Desktop.
Save oomusou/f84b670292c2c34df701076300b442a9 to your computer and use it in GitHub Desktop.
<template>
<div id="counter">
<h1>{{ showCount }}</h1>
<button @click="addCount(1)">+</button>
</div>
</template>
<script>
import { mapMutations, mapState } from 'vuex';
const mapStates = () =>
mapState('counter', {
count: state => state.count,
});
const showCount = function() {
return `Counter : ${this.count}`;
};
const computed = {
...mapStates(),
showCount,
};
const methods = {
...mapMutations('counter', ['addCount']),
};
export default {
name: 'counter',
computed,
methods,
};
</script>
<style scoped>
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment