返回 slidev
Counter.vue
1 <script setup lang="ts">
2 import { ref } from 'vue'
3
4 const props = defineProps({
5 count: {
6 default: 0,
7 },
8 })
9
10 const counter = ref(props.count)
11 </script>
12
13 <template>
14 <div flex="~" w="min" border="~ main rounded-md">
15 <button
16 border="r main"
17 p="2"
18 font="mono"
19 outline="!none"
20 hover:bg="gray-400 opacity-20"
21 @click="counter -= 1"
22 >
23 -
24 </button>
25 <span m="auto" p="2">{{ counter }}</span>
26 <button
27 border="l main"
28 p="2"
29 font="mono"
30 outline="!none"
31 hover:bg="gray-400 opacity-20"
32 @click="counter += 1"
33 >
34 +
35 </button>
36 </div>
37 </template>
38
38 lines Plain Text