Package Exports
- vue-use-query
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vue-use-query) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Vue Query
Hooks for fetching, caching and updating asynchronous data in Vue.
documentation
保持与react-query一样的API
Visit https://react-query.tanstack.com/
Quick sTART
- Attach Vue Query to the root component of your Vue application
<template>
<query-client-provider :client="queryClient">
<router-view />
</query-client-provider>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { QueryClientProvider, QueryClient } from '@/vue-query';
const queryClient = new QueryClient();
queryClient.setDefaultOptions();
export default defineComponent({
name: 'APP',
components: {
QueryClientProvider,
},
setup() {
return {
queryClient,
};
},
});
</script>
- Use query and search projects to demonstrate
function useSearchProjects() {
const searchValue = useQueryString('search');
const debounceSearchValue = useDebounce(searchValue);
const personId = useQueryString('personId');
const result = useQuery<IProject[]>(
['projects', debounceSearchValue, personId],
() => {
return window.fetch('/projects', {
data: {
search: debounceSearchValue.value,
personId: personId.value,
},
});
}
);
return [
result,
{
searchValue,
personId,
},
] as const;
}