mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 01:53:55 +00:00
173fbfd06e
* 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>
20 lines
509 B
Vue
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>
|