2023-08-24 12:06:29 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div>immediate-remove-unmounted.vue</div>
|
|
|
|
<div id="immediate-data">
|
2024-05-21 22:58:38 +00:00
|
|
|
{{ data === null ? "null" : (data === undefined ? 'undefined' : data) }}
|
2023-08-24 12:06:29 +00:00
|
|
|
</div>
|
2023-11-09 17:01:13 +00:00
|
|
|
<button
|
|
|
|
id="execute-btn"
|
|
|
|
@click="execute"
|
|
|
|
>
|
2023-08-24 12:06:29 +00:00
|
|
|
execute
|
|
|
|
</button>
|
2023-11-09 17:01:13 +00:00
|
|
|
<NuxtLink
|
|
|
|
id="to-index"
|
|
|
|
to="/"
|
|
|
|
>
|
2023-08-24 12:06:29 +00:00
|
|
|
index
|
|
|
|
</NuxtLink>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-05-21 22:58:38 +00:00
|
|
|
import { asyncDataDefaults } from '#build/nuxt.config.mjs'
|
|
|
|
|
2023-08-24 12:06:29 +00:00
|
|
|
const { data, execute } = await useAsyncData('immediateFalse', () => $fetch('/api/random'), { immediate: false })
|
|
|
|
|
2024-05-21 22:58:38 +00:00
|
|
|
if (data.value !== asyncDataDefaults.errorValue) {
|
|
|
|
throw new Error(`Initial data should be ${asyncDataDefaults.errorValue}: ` + data.value)
|
2023-08-24 12:06:29 +00:00
|
|
|
}
|
|
|
|
</script>
|