2022-03-30 15:59:28 +00:00
|
|
|
<script setup>
|
|
|
|
const counter = useState('counter', () => Math.round(Math.random() * 1000))
|
2022-05-20 09:12:35 +00:00
|
|
|
const sameCounter = useState('counter');
|
2022-03-30 15:59:28 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-03-31 13:31:04 +00:00
|
|
|
<NuxtExampleLayout example="composables/use-state">
|
2022-03-30 15:59:28 +00:00
|
|
|
<div>Counter: {{ counter }}</div>
|
2022-05-20 09:12:35 +00:00
|
|
|
<div>Same Counter: {{ sameCounter }}</div>
|
2022-03-30 15:59:28 +00:00
|
|
|
<div>
|
|
|
|
<NButton class="font-mono" @click="counter++">
|
|
|
|
+
|
|
|
|
</NButton>
|
|
|
|
<NButton class="font-mono" @click="counter--">
|
|
|
|
-
|
|
|
|
</NButton>
|
|
|
|
</div>
|
|
|
|
</NuxtExampleLayout>
|
|
|
|
</template>
|