examples/vue/2.6-basic
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
TanStack Vue Query 2.6 Basic Example#
The basic posts example on Vue 2.6.
How it works#
src/services/posts/queries.tsdefinespostsQueries.list()andpostsQueries.detail(id),queryOptionsfactories keyed by['posts', 'list']and['posts', 'detail', id].src/Posts.vuereads the list withuseQuery(postsQueries.list())and marks a post as visited whenqueryClient.getQueryData(postsQueries.detail(item.id).queryKey)returns data.src/Post.vuepasses a getter,useQuery(() => postsQueries.detail(props.postId)), so the query follows thepostIdprop. A cached post renders at once and shows "Background Updating..." whileisFetchingistrue.src/main.tsinstalls@vue/composition-apiandVueQueryPluginwithVue.use, then mounts the app withcreateAppfrom@vue/composition-api.
To run this example:
npm installnpm run dev