Open History to see the last commit
1# TanStack Vue Query 2.6 Basic Example
2β
3The basic posts example on Vue 2.6.
4β
5## How it works
6β
7- `src/services/posts/queries.ts` defines `postsQueries.list()` and `postsQueries.detail(id)`, `queryOptions` factories keyed by `['posts', 'list']` and `['posts', 'detail', id]`.
8- `src/Posts.vue` reads the list with `useQuery(postsQueries.list())` and marks a post as visited when `queryClient.getQueryData(postsQueries.detail(item.id).queryKey)` returns data.
9- `src/Post.vue` passes a getter, `useQuery(() => postsQueries.detail(props.postId))`, so the query follows the `postId` prop. A cached post renders at once and shows "Background Updating..." while `isFetching` is `true`.
10- `src/main.ts` installs `@vue/composition-api` and `VueQueryPlugin` with `Vue.use`, then mounts the app with `createApp` from `@vue/composition-api`.
11β
12To run this example:
13β
14- `npm install`
15- `npm run dev`