mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
48d886c860
* docs: add documents for use-error,use-lazy-async-data and use-lazy-fetch * docs(API): document useError,useLazyAsyncData and useLazyFetch Co-authored-by: xiaojie.jiang <xiaojie.jiang@dhc.com.cn>
819 B
819 B
useLazyAsyncData
This composable behaves identically to useAsyncData with the lazy: true
option set.
Otherwise, this function does not block navigation. That means you will need to handle the situation where the data is null
(or whatever value you have provided in a custom default
factory function).
::ReadMore{link="/api/composables/use-async-data"} ::
Example
<template>
<div>
{{ pending ? 'Loading' : count }}
</div>
</template>
<script setup>
const { pending, data: count } = useLazyAsyncData('count', () => $fetch('/api/count'))
watch(count, (newCount) => {
// Because count starts out null, you won't have access
// to its contents immediately, but you can watch it.
})
</script>
::ReadMore{link="/guide/features/data-fetching"} ::