diff --git a/02-basics-2/10-counter/CounterApp.js b/02-basics-2/10-counter/CounterApp.js index e0d3101..18318bd 100644 --- a/02-basics-2/10-counter/CounterApp.js +++ b/02-basics-2/10-counter/CounterApp.js @@ -1,9 +1,25 @@ -import { defineComponent } from 'vue' +import { defineComponent, ref } from 'vue' export default defineComponent({ name: 'CounterApp', - setup() {}, + setup() { + const counter = ref(0); + + function increase() { + counter.value++; + } + + function decrease() { + counter.value--; + } + + return { + counter, + increase, + decrease, + } + }, template: `
@@ -11,15 +27,18 @@ export default defineComponent({ class="button button--secondary" type="button" aria-label="Decrement" - disabled + :disabled="counter === 0" + @click="decrease" >➖ - 0 + {{ counter }}
`,