Nuxt/examples/composables/use-state/app.vue
HG 173fbfd06e
docs: demonstrate the multiple useState with same key (#5059)
* Better demonstrate the UseState concept

Add another counter instance with the same id and show that they change in parallel

* Apply suggestions from code review

Co-authored-by: pooya parsa <pyapar@gmail.com>
2022-05-20 11:12:35 +02:00

20 lines
509 B
Vue

<script setup>
const counter = useState('counter', () => Math.round(Math.random() * 1000))
const sameCounter = useState('counter');
</script>
<template>
<NuxtExampleLayout example="composables/use-state">
<div>Counter: {{ counter }}</div>
<div>Same Counter: {{ sameCounter }}</div>
<div>
<NButton class="font-mono" @click="counter++">
+
</NButton>
<NButton class="font-mono" @click="counter--">
-
</NButton>
</div>
</NuxtExampleLayout>
</template>