Newer
Older
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<template>
<div>
<p>External counter:</p>
<div class="row">
<button @click="$emit('input', value - 1)">-</button>
{{ value }}
<button @click="$emit('input', value + 1)">+</button>
</div>
<p>Internal counter:</p>
<div class="row">
<button @click="count--">-</button>
{{ count }}
<button @click="count++">+</button>
</div>
</div>
</template>
<script>
export default {
name: "NumberCounter",
props: {
value: Number,
},
emits: ["input"],
data() {
return {
count: 0,
};
},
};
</script>
<style scoped>
div {
background: #2c3e50;
color: white;
display: flex;
flex-direction: column;
align-items: center;
padding: 1em;
gap: 3px;
}
div.row {
flex-direction: row;
gap: 1em;
}
</style>