snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
9
examples/vue/simple/.gitignore
vendored
Normal file
9
examples/vue/simple/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
node_modules
|
||||
.DS_Store
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
pnpm-lock.yaml
|
||||
6
examples/vue/simple/README.md
Normal file
6
examples/vue/simple/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# Simple example
|
||||
|
||||
To run this example:
|
||||
|
||||
- `npm install` or `yarn` or `pnpm i` or `bun i`
|
||||
- `npm run dev` or `yarn dev` or `pnpm dev` or `bun dev`
|
||||
12
examples/vue/simple/index.html
Normal file
12
examples/vue/simple/index.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>TanStack Query Vue Simple Example App</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
20
examples/vue/simple/package.json
Normal file
20
examples/vue/simple/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@tanstack/query-example-vue-simple",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tanstack/vue-query": "^5.102.8",
|
||||
"@tanstack/vue-query-devtools": "^6.1.48",
|
||||
"vue": "^3.4.27"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"typescript": "5.8.3",
|
||||
"vite": "^6.4.1"
|
||||
}
|
||||
}
|
||||
43
examples/vue/simple/src/App.vue
Normal file
43
examples/vue/simple/src/App.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
import { useQuery } from '@tanstack/vue-query'
|
||||
import { VueQueryDevtools } from '@tanstack/vue-query-devtools'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'App',
|
||||
components: { VueQueryDevtools },
|
||||
setup() {
|
||||
const { data, error, isFetching, isPending } = useQuery({
|
||||
queryKey: ['repoData'],
|
||||
async queryFn() {
|
||||
return await fetch('https://api.github.com/repos/Tanstack/query').then(
|
||||
(response) => response.json(),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
return {
|
||||
data,
|
||||
error,
|
||||
isFetching,
|
||||
isPending,
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="isPending"> Loading... </template>
|
||||
<template v-else-if="error">
|
||||
'An error has occurred: {{ error.message }}
|
||||
</template>
|
||||
<template v-else>
|
||||
<h1>{{ data.name }}</h1>
|
||||
<p>{{ data.description }}</p>
|
||||
<strong>👀 {{ data.subscribers_count }}</strong>
|
||||
<strong>✨ {{ data.stargazers_count }}</strong>
|
||||
<strong>🍴 {{ data.forks_count }}</strong>
|
||||
<div>{{ isFetching ? 'Updating...' : '' }}</div>
|
||||
</template>
|
||||
<VueQueryDevtools />
|
||||
</template>
|
||||
6
examples/vue/simple/src/main.ts
Normal file
6
examples/vue/simple/src/main.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createApp } from 'vue'
|
||||
import { VueQueryPlugin } from '@tanstack/vue-query'
|
||||
|
||||
import App from './App.vue'
|
||||
|
||||
createApp(App).use(VueQueryPlugin).mount('#app')
|
||||
5
examples/vue/simple/src/shims-vue.d.ts
vendored
Normal file
5
examples/vue/simple/src/shims-vue.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
declare module '*.vue' {
|
||||
import { DefineComponent } from 'vue'
|
||||
const component: DefineComponent<{}, {}, any>
|
||||
export default component
|
||||
}
|
||||
6
examples/vue/simple/src/types.d.ts
vendored
Normal file
6
examples/vue/simple/src/types.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export interface Post {
|
||||
userId: number
|
||||
id: number
|
||||
title: string
|
||||
body: string
|
||||
}
|
||||
15
examples/vue/simple/tsconfig.json
Normal file
15
examples/vue/simple/tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
"sourceMap": true,
|
||||
"resolveJsonModule": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["esnext", "dom"],
|
||||
"types": ["vite/client"]
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue"]
|
||||
}
|
||||
9
examples/vue/simple/vite.config.ts
Normal file
9
examples/vue/simple/vite.config.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
optimizeDeps: {
|
||||
exclude: ['@tanstack/vue-query', 'vue-demi'],
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user