From 88df3320c98d97086c5b6353e17b86016362b595 Mon Sep 17 00:00:00 2001 From: Kira Date: Wed, 25 Dec 2024 22:50:19 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D1=81=D1=87=D0=B5=D1=82=D1=87=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02-basics-2/10-counter/CounterApp.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) 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 }}
`,