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