mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
feat: add reactive inputs
This commit is contained in:
29
playground/pages/reactive.vue
Normal file
29
playground/pages/reactive.vue
Normal file
@@ -0,0 +1,29 @@
|
||||
<script setup lang="ts">
|
||||
const route = useRoute()
|
||||
const { $client } = useNuxtApp()
|
||||
const id = ref(1)
|
||||
// const { data: todo, pending, error } = await useAsyncData(() => $client.todo.getTodo.query(id.value), {
|
||||
// watch: [id]
|
||||
// })
|
||||
|
||||
const { data: todo, pending, error, refresh } = await $client.todo.getTodo.useQuery(id, {
|
||||
watch: [id],
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="pending">
|
||||
Loading...
|
||||
</div>
|
||||
<div v-else-if="error?.data?.code">
|
||||
Error: {{ error.data.code }}
|
||||
</div>
|
||||
<div v-else>
|
||||
ID: {{ todo?.id }} <br>
|
||||
Title: {{ todo?.title }} <br>
|
||||
Completed: {{ todo?.completed }}
|
||||
</div>
|
||||
<button @click="id++">
|
||||
Next Todo
|
||||
</button>
|
||||
</template>
|
||||
Reference in New Issue
Block a user