blob: 8179fb1d90d3a65feef6679d3c10fb00cedecbd0 (
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
 | <template>
  <div class="counter">
      <button @click="subtract()">-</button>
      <pre>{{ count }}</pre>
      <button @click="add()">+</button>
  </div>
  <div class="children">
      <slot />
  </div>
</template>
<script>
import { ref } from 'vue';
export default {
  setup() {
    const count = ref(0)
    const add = () => count.value = count.value + 1;
    const subtract = () => count.value = count.value - 1;
    return {
      count,
      add,
      subtract
    }
  }
}
</script>
 |