summaryrefslogtreecommitdiff
path: root/examples/framework-vue/src/components/Counter.vue
diff options
context:
space:
mode:
authorGravatar Shinya Fujino <shf0811@gmail.com> 2023-12-11 17:14:28 +0900
committerGravatar GitHub <noreply@github.com> 2023-12-11 16:14:28 +0800
commita0dc4a43572f45c5e26f5a470cb7f9c47fb9f542 (patch)
treecae3461908bb311e1e03fe5fa96ec21c464593da /examples/framework-vue/src/components/Counter.vue
parentbebf5cf22d0d842670825aa961529e8b342e2b26 (diff)
downloadastro-a0dc4a43572f45c5e26f5a470cb7f9c47fb9f542.tar.gz
astro-a0dc4a43572f45c5e26f5a470cb7f9c47fb9f542.tar.zst
astro-a0dc4a43572f45c5e26f5a470cb7f9c47fb9f542.zip
Refactor Vue example to use `<script setup>` (#9379)
Diffstat (limited to 'examples/framework-vue/src/components/Counter.vue')
-rw-r--r--examples/framework-vue/src/components/Counter.vue29
1 files changed, 10 insertions, 19 deletions
diff --git a/examples/framework-vue/src/components/Counter.vue b/examples/framework-vue/src/components/Counter.vue
index 5ce5352b8..11f2bf1b5 100644
--- a/examples/framework-vue/src/components/Counter.vue
+++ b/examples/framework-vue/src/components/Counter.vue
@@ -1,31 +1,22 @@
+<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>
+ <button @click="subtract">-</button>
<pre>{{ count }}</pre>
- <button @click="add()">+</button>
+ <button @click="add">+</button>
</div>
<div class="counter-message">
<slot />
</div>
</template>
-<script lang="ts">
-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>
-
<style>
.counter {
display: grid;