-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add simple example for document homepage (#6857)
* docs: add simple example for document homepage * chore: run prettier
- Loading branch information
1 parent
3b6c32a
commit 5f1b505
Showing
11 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
package-lock.json | ||
yarn.lock | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Basic example | ||
|
||
To run this example: | ||
|
||
- `npm install` or `yarn` or `pnpm i` | ||
- `npm run dev` or `yarn dev` or `pnpm dev` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.18.1", | ||
"@tanstack/vue-query-devtools": "^5.18.1", | ||
"vue": "^3.3.0" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-vue": "^4.5.2", | ||
"typescript": "5.2.2", | ||
"vite": "^5.0.10" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
declare module '*.vue' { | ||
import { DefineComponent } from 'vue' | ||
const component: DefineComponent<{}, {}, any> | ||
export default component | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface Post { | ||
userId: number | ||
id: number | ||
title: string | ||
body: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"strict": true, | ||
"jsx": "preserve", | ||
"sourceMap": true, | ||
"resolveJsonModule": true, | ||
"esModuleInterop": true, | ||
"lib": ["esnext", "dom"], | ||
"types": ["vite/client"] | ||
}, | ||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.vue"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'], | ||
}, | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.