Detailed changes
Use
vue-demito be compatible with vue2.Add
getCache、setCache、clearCache.When caching is enabled, requests with the same
cacheKeyset will be reused.Add
runAsyncandrefreshAsync, the original run no longer returns Promise.Add
definePluginto extend theuseReuqest.In
debounce/throttlemode,runAsynccan return current Promise.Add
useRequestProviderto inject the options.Add
refreshDepsActionoption to customize the behavior afterrefreshDepsis triggered.Add
loadingKeep.refreshDepsAction在manual=true时,也会被refreshDeps的改变而触发。The request library is no longer integrated by default, and service no longer supports string or object.
Remove
formatResult. Migration helpRemove
queryKey, that is, deleted concurrent request. Migration helprunno longer returns Promise Migration helpdatais no longer emptied when a request failsUpgraded
readybehaviordataanderrorchanged toshallowRefusePaginationremoves thereloadmethod andreloading. If you need the corresponding requirements, you can implement it yourself.Remove
RequestConfigcomponent. Migration helpRefactored
useLoadMore. see alsocacheKeySupport passing in functions:cacheKey: (params?: P) => stringuseRequest(getUser, { cacheKey: (params?: P): string => { if (params) { return `user-key-${params[0].name}`; } return ''; }, });Some
optionssupport reactive as followstype ReactivityOptions = { loadingDelay: number | Ref<number>; pollingInterval: number | Ref<number>; debounceInterval: number | Ref<number>; debounceOptions: DebounceOptions | Reactive<DebounceOptions>; throttleInterval: number | Ref<number>; throttleOptions: ThrottleOptions | Reactive<ThrottleOptions>; refreshOnWindowFocus: boolean | Ref<boolean>; refocusTimespan: number | Ref<number>; errorRetryCount: number | Ref<number>; errorRetryInterval: number | Ref<number>; };
Migration help
formatResultis deleted, and the service is expected to return the data in the final format. for example:
const getUser = async () => {
const results = await axios.get('api/user');
// Process the final data here
return results.data;
};
