snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
45
docs/framework/vue/guides/background-fetching-indicators.md
Normal file
45
docs/framework/vue/guides/background-fetching-indicators.md
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
id: background-fetching-indicators
|
||||
title: Background Fetching Indicators
|
||||
ref: docs/framework/react/guides/background-fetching-indicators.md
|
||||
---
|
||||
|
||||
[//]: # 'Example'
|
||||
|
||||
```vue
|
||||
<script setup>
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
|
||||
const { isPending, isFetching, isError, data, error } = useQuery({
|
||||
queryKey: ['todos'],
|
||||
queryFn: getTodos,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="isFetching">Refreshing...</div>
|
||||
<span v-if="isPending">Loading...</span>
|
||||
<span v-else-if="isError">Error: {{ error.message }}</span>
|
||||
<!-- We can assume by this point that `isSuccess === true` -->
|
||||
<ul v-else-if="data">
|
||||
<li v-for="todo in data" :key="todo.id">{{ todo.title }}</li>
|
||||
</ul>
|
||||
</template>
|
||||
```
|
||||
|
||||
[//]: # 'Example'
|
||||
[//]: # 'Example2'
|
||||
|
||||
```vue
|
||||
<script setup>
|
||||
import { useIsFetching } from '@tanstack/vue-query'
|
||||
|
||||
const isFetching = useIsFetching()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="isFetching">Queries are fetching in the background...</div>
|
||||
</template>
|
||||
```
|
||||
|
||||
[//]: # 'Example2'
|
||||
Reference in New Issue
Block a user