Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

App.vue

29 lines915 Bytes

1<script setup lang="ts">
2import { ref } from 'vue'
3import { VueQueryDevtools } from '@tanstack/vue-query-devtools'
4​
5import PostList from './PostList.vue'
6import PostDetail from './PostDetail.vue'
7​
8const postId = ref(-1)
9const setPostId = (id: number) => {
10 postId.value = id
12</script>
13​
14<template>
15 <h1>Vue Query - Basic</h1>
16 <p>
17 As you visit the posts below, you will notice them in a loading state the
18 first time you load them. However, after you return to this list and click
19 on any posts you have already visited again, you will see them load
20 instantly and background refresh right before your eyes!
21 <strong>
22 (You may need to throttle your network speed to simulate longer loading
23 sequences)
24 </strong>
25 </p>
26 <PostDetail v-if="postId > -1" :post-id="postId" @set-post-id="setPostId" />
27 <PostList v-else @set-post-id="setPostId" />
28 <VueQueryDevtools />
29</template>