Open History to see the last commit
1<script setup lang="ts">
2import { ref } from 'vue'
3β
4import PostList from './PostList.vue'
5import PostDetail from './PostDetail.vue'
6β
7const postId = ref(-1)
8const setPostId = (id: number) => {
9 postId.value = id
10}
11</script>
12β
13<template>
14 <h1>Vue Query - Dependent Queries</h1>
15 <p>
16 As you visit the posts below, you will notice them in a loading state the
17 first time you load them. However, after you return to this list and click
18 on any posts you have already visited again, you will see them load
19 instantly and background refresh right before your eyes!
20 <br />
21 You will also notice, that after some time the name of the author gets
22 loaded. This data is not directly included in the
23 <code>/posts/id</code> response but gets fetched when the post gets loaded
24 from its <code>userId</code>.
25 <strong>
26 (You may need to throttle your network speed to simulate longer loading
27 sequences)
28 </strong>
29 </p>
30 <PostDetail v-if="postId > -1" :post-id="postId" @set-post-id="setPostId" />
31 <PostList v-else @set-post-id="setPostId" />
32</template>