2022-09-10 13:57:16 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2022-09-13 20:20:23 +00:00
|
|
|
<NuxtLink to="/" prefetched-class="prefetched">
|
|
|
|
Home
|
|
|
|
</NuxtLink>
|
|
|
|
<NuxtLink to="/random/a" prefetched-class="prefetched">
|
2022-09-10 13:57:16 +00:00
|
|
|
Random (A)
|
|
|
|
</NuxtLink>
|
2022-09-13 20:20:23 +00:00
|
|
|
<NuxtLink to="/random/b" prefetched-class="prefetched">
|
2022-09-10 13:57:16 +00:00
|
|
|
Random (B)
|
|
|
|
</NuxtLink>
|
2022-09-13 20:20:23 +00:00
|
|
|
<NuxtLink to="/random/c" prefetched-class="prefetched">
|
2022-09-10 13:57:16 +00:00
|
|
|
Random (C)
|
|
|
|
</NuxtLink>
|
|
|
|
<br>
|
|
|
|
|
|
|
|
Random: {{ random }}
|
|
|
|
|
|
|
|
Random: (global) {{ globalRandom }}
|
|
|
|
|
|
|
|
Random page: <b>{{ route.params.id }}</b><br>
|
|
|
|
|
|
|
|
Here are some random numbers for you:
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li v-for="n in randomNumbers" :key="n">
|
|
|
|
{{ n }}
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<button @click="() => refresh()">
|
|
|
|
Give me another set
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
const pageKey = 'rand_' + route.params.id
|
|
|
|
|
|
|
|
const { data: randomNumbers, refresh } = await useFetch('/api/random', { key: pageKey as string })
|
|
|
|
|
|
|
|
const random = useRandomState(100, pageKey)
|
|
|
|
const globalRandom = useRandomState(100)
|
|
|
|
</script>
|
2022-09-13 20:20:23 +00:00
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.prefetched {
|
|
|
|
color: green;
|
|
|
|
}
|
|
|
|
</style>
|