diff options
author | 2023-12-11 17:14:28 +0900 | |
---|---|---|
committer | 2023-12-11 16:14:28 +0800 | |
commit | a0dc4a43572f45c5e26f5a470cb7f9c47fb9f542 (patch) | |
tree | cae3461908bb311e1e03fe5fa96ec21c464593da /examples/framework-vue/src/components/Counter.vue | |
parent | bebf5cf22d0d842670825aa961529e8b342e2b26 (diff) | |
download | astro-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.vue | 29 |
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; |