2021-11-16 13:17:52 +00:00
|
|
|
<script setup>
|
2021-11-16 15:37:36 +00:00
|
|
|
const counter = useState('counter', () => Math.round(Math.random() * 1000))
|
2021-11-16 13:17:52 +00:00
|
|
|
</script>
|
|
|
|
|
2021-10-11 17:48:03 +00:00
|
|
|
<template>
|
2022-03-23 08:44:36 +00:00
|
|
|
<NuxtExampleLayout show-tips example="use-state">
|
2021-12-23 19:27:08 +00:00
|
|
|
<div>Counter: {{ counter }}</div>
|
|
|
|
<div>
|
|
|
|
<NButton class="font-mono" @click="counter++">
|
|
|
|
+
|
|
|
|
</NButton>
|
|
|
|
<NButton class="font-mono" @click="counter--">
|
|
|
|
-
|
|
|
|
</NButton>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<template #tips>
|
|
|
|
<div>
|
2022-03-18 10:59:02 +00:00
|
|
|
<NuxtLink to="https://v3.nuxtjs.org/docs/usage/state" target="_blank">
|
2021-12-23 19:27:08 +00:00
|
|
|
useState
|
2022-03-18 10:59:02 +00:00
|
|
|
</NuxtLink>
|
2021-12-23 19:27:08 +00:00
|
|
|
is an SSR-friendly ref replacement.
|
|
|
|
Its value will be preserved after server-side rendering
|
|
|
|
and shared across all components using a unique key.
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</NuxtExampleLayout>
|
2021-10-11 17:48:03 +00:00
|
|
|
</template>
|