sluggard-query-vue
v0.0.3
Published
基于 tanstack/vue-query 的 data-fetching 库,与 tanstack 使用方式兼容。
Downloads
28
Maintainers
Readme
快速开始
安装
请确保已安装 [@tanstack/vue-query](@tanstack/vue-query - npm (npmjs.com)),并完成配置。
pnpm add sluggard-query-vue
使用
import { ref } from 'vue'
import { usePaginationQuery } from 'sluggard-query-vue'
import { fetcher } from '你的查询请求函数'
const state = ref({})
const query = usePaginationQuery(fetcher, state)
类型
type usePaginationQuery = (
fetcher: (filterData: any) => Promise<any>, // 请求函数
filterData?: Ref<any> | null, // 过滤查询参数
config?: UsePaginationQueryConfigType // 配置项 详见文档
) =>
| {
current: Ref<number>; // 当前页数
pageSize: Ref<number>; // 每页条数
list: Ref<never[]>; // 列表数据体
total: Ref<number>; // 数据总数
refetch: (
_injectData?: any,
options?: RefetchOptions
) => Promise<any> | undefined; // 手动重新获取查询的函数
}
| UseQueryReturnType; // tanstack/vue-query useQuery 返回参数