Skip to content

Commit

Permalink
basics-2 counter
Browse files Browse the repository at this point in the history
  • Loading branch information
alnusglutinosa committed Dec 30, 2024
1 parent 335cf74 commit 7ade2cf
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions 02-basics-2/10-counter/CounterApp.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
import { defineComponent } from 'vue'
import { defineComponent, ref } from 'vue'

export default defineComponent({
name: 'CounterApp',

setup() {},
setup() {
const counter = ref(0);

function onClickDecrement() {
counter.value--;
}


function onClickIncrement() {
counter.value++;
}


return {
counter,
onClickDecrement,
onClickIncrement,
}
},

template: `
<div class="counter">
<button
class="button button--secondary"
type="button"
aria-label="Decrement"
disabled
:disabled="counter === 0"
@click="onClickDecrement"
>➖</button>
<span class="count" data-testid="count">0</span>
<span class="count" data-testid="count">
{{ counter }}
</span>
<button
class="button button--secondary"
type="button"
aria-label="Increment"
:disabled="counter === 5"
@click="onClickIncrement"
>➕</button>
</div>
`,
Expand Down

0 comments on commit 7ade2cf

Please sign in to comment.