blob: 11f2bf1b5051f79e6ea270dc44edb5b2e81023f0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<script setup lang="ts">
import { ref } from 'vue';
const count = ref(0);
const add = () => count.value++;
const subtract = () => count.value--;
</script>
<template>
<div class="counter">
<button @click="subtract">-</button>
<pre>{{ count }}</pre>
<button @click="add">+</button>
</div>
<div class="counter-message">
<slot />
</div>
</template>
<style>
.counter {
display: grid;
font-size: 2em;
grid-template-columns: repeat(3, minmax(0, 1fr));
margin-top: 2em;
place-items: center;
}
.counter-message {
text-align: center;
}
</style>
|