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

App.vue

39 lines1.0 KB

1<script lang="ts">
2import { defineComponent, ref } from '@vue/composition-api'
3import Post from './Post.vue'
4import Posts from './Posts.vue'
5​
6export default defineComponent({
7 name: 'App',
8 components: { Posts, Post },
9 setup() {
10 const postId = ref(-1)
11 const setPostId = (id: number) => {
12 postId.value = id
13 }
14​
15 return {
16 postId,
17 setPostId,
18 }
19 },
20})
21</script>
22​
23<template>
24 <div>
25 <h1>Vue Query - Basic</h1>
26 <p>
27 As you visit the posts below, you will notice them in a loading state the
28 first time you load them. However, after you return to this list and click
29 on any posts you have already visited again, you will see them load
30 instantly and background refresh right before your eyes!
31 <strong>
32 (You may need to throttle your network speed to simulate longer loading
33 sequences)
34 </strong>
35 </p>
36 <Post v-if="postId > -1" :postId="postId" @setPostId="setPostId" />
37 <Posts v-else @setPostId="setPostId" />
38 </div>
39</template>