mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 00:52:01 +00:00
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>
This commit is contained in:
parent
cad9ce4a6a
commit
173fbfd06e
@ -1,10 +1,12 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
const counter = useState('counter', () => Math.round(Math.random() * 1000))
|
const counter = useState('counter', () => Math.round(Math.random() * 1000))
|
||||||
|
const sameCounter = useState('counter');
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NuxtExampleLayout example="composables/use-state">
|
<NuxtExampleLayout example="composables/use-state">
|
||||||
<div>Counter: {{ counter }}</div>
|
<div>Counter: {{ counter }}</div>
|
||||||
|
<div>Same Counter: {{ sameCounter }}</div>
|
||||||
<div>
|
<div>
|
||||||
<NButton class="font-mono" @click="counter++">
|
<NButton class="font-mono" @click="counter++">
|
||||||
+
|
+
|
||||||
|
Loading…
Reference in New Issue
Block a user