Last active
April 2, 2018 16:59
-
-
Save mfaridzia/55d6be6f5bddc29dae3db490c6c59061 to your computer and use it in GitHub Desktop.
This file contains 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="app"> | |
<div class="counter"> {{ counter }} </div> | |
<button @click="increment" class="increment"> Tambah </button> | |
<button @click="decrement" class="decrement"> Kurangi </button> | |
</div> | |
</template> | |
<script> | |
export default { | |
methods: { | |
increment() { | |
this.$store.commit('increment') | |
}, | |
decrement() { | |
this.$store.commit('decrement') | |
} | |
}, | |
computed: { | |
counter() { | |
return this.$store.getters.getCounter | |
} | |
} | |
} | |
</script> | |
<style scoped> | |
#app { | |
width: 30%; | |
margin: 100px auto; | |
background: #f1f1f1; | |
padding: 15px; | |
} | |
.counter { | |
width: 70%; | |
padding: 50px 5px; | |
margin: 20px auto; | |
background: #3498db; | |
color:#fff; | |
font-size: 100px; | |
} | |
button { | |
border: 0; | |
padding: 13px 45px; | |
font-weight: bold; | |
margin-bottom: 20px; | |
} | |
.increment { | |
background: #2c3e50; | |
color: #fff; | |
} | |
.increment:hover { | |
transition: .7s; | |
opacity: 0.8; | |
cursor: pointer; | |
} | |
.decrement { | |
background: #c0392b; | |
color: #fff; | |
} | |
.decrement:hover { | |
transition: .7s; | |
opacity: 0.9; | |
cursor: pointer; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment