Created
September 25, 2018 06:40
-
-
Save oomusou/f84b670292c2c34df701076300b442a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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