From 7a91c577eeb979f4c2bb66810b477dd2556f1d06 Mon Sep 17 00:00:00 2001 From: jiasheng Date: Wed, 23 Apr 2025 09:24:51 +0800 Subject: [PATCH 1/2] doc: add computed tip for vue query --- docs/reference/plugins/tanstack-query.mdx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/reference/plugins/tanstack-query.mdx b/docs/reference/plugins/tanstack-query.mdx index a35ff848..1fdf5b08 100644 --- a/docs/reference/plugins/tanstack-query.mdx +++ b/docs/reference/plugins/tanstack-query.mdx @@ -422,6 +422,18 @@ const onCreate = () => { ``` +::: tip + If the query parameters are not constant, you need to wrap the query in a `computed` to make it reactive. +```ts +const queryParams = computed(() => ({ + where: { + space: { slug: route.params.slug as string }, + id: meQuery.data.value?.userId + }, +})); +const { data: posts } = useFindManyPost(queryParams); +``` +::: From d832d7e89fa236a3d0f02bfdb3bacb12e2125c1c Mon Sep 17 00:00:00 2001 From: jiasheng Date: Wed, 23 Apr 2025 09:27:13 +0800 Subject: [PATCH 2/2] fix typo --- docs/reference/plugins/tanstack-query.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/plugins/tanstack-query.mdx b/docs/reference/plugins/tanstack-query.mdx index 1fdf5b08..9f54ef75 100644 --- a/docs/reference/plugins/tanstack-query.mdx +++ b/docs/reference/plugins/tanstack-query.mdx @@ -422,7 +422,7 @@ const onCreate = () => { ``` -::: tip +:::tip If the query parameters are not constant, you need to wrap the query in a `computed` to make it reactive. ```ts const queryParams = computed(() => ({