Docs
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
CodeRabbit
Cloudflare
AG Grid
SerpAPI
Netlify
OpenRouter
Neon
WorkOS
Clerk
Electric
PowerSync
Sentry
Railway
Prisma
Strapi
Unkey
API Reference

Vue Example: 2.6 Basic

<script lang="ts">
import { defineComponent, ref } from '@vue/composition-api'

import Posts from './Posts.vue'
import Post from './Post.vue'

export default defineComponent({
  name: 'App',
  components: { Posts, Post },
  setup() {
    const postId = ref(-1)
    const setPostId = (id: number) => {
      postId.value = id
    }

    return {
      postId,
      setPostId,
    }
  },
})
</script>

<template>
  <div>
    <h1>Vue Query - Basic</h1>
    <p>
      As you visit the posts below, you will notice them in a loading state the
      first time you load them. However, after you return to this list and click
      on any posts you have already visited again, you will see them load
      instantly and background refresh right before your eyes!
      <strong>
        (You may need to throttle your network speed to simulate longer loading
        sequences)
      </strong>
    </p>
    <Post v-if="postId > -1" :postId="postId" @setPostId="setPostId" />
    <Posts v-else @setPostId="setPostId" />
  </div>
</template>
<script lang="ts">
import { defineComponent, ref } from '@vue/composition-api'

import Posts from './Posts.vue'
import Post from './Post.vue'

export default defineComponent({
  name: 'App',
  components: { Posts, Post },
  setup() {
    const postId = ref(-1)
    const setPostId = (id: number) => {
      postId.value = id
    }

    return {
      postId,
      setPostId,
    }
  },
})
</script>

<template>
  <div>
    <h1>Vue Query - Basic</h1>
    <p>
      As you visit the posts below, you will notice them in a loading state the
      first time you load them. However, after you return to this list and click
      on any posts you have already visited again, you will see them load
      instantly and background refresh right before your eyes!
      <strong>
        (You may need to throttle your network speed to simulate longer loading
        sequences)
      </strong>
    </p>
    <Post v-if="postId > -1" :postId="postId" @setPostId="setPostId" />
    <Posts v-else @setPostId="setPostId" />
  </div>
</template>