vue-request
vue-request copied to clipboard
⚡️ This is a library that can easily help you manage request states, supporting common features such as SWR, polling, error retry, caching, and pagination, etc. ⚡️ 这是一个能够轻松帮助你管理请求状态...
在大数据轮询场景下 需要手动对数据进行对比 找出不同的数据 再进行patch 。 patch需要在旧的数据中进行 避免引用地址变化触发大量vue组件的更新 思路:暴露一个配置函数 每次请求成功 如果存在这个函数 那么data字段的管理交由该函数处理 否则 走现有的逻辑 。 mutate方法也是如此 思路2:核心库改写为类 同时默认导出一个实例以向前兼容api。 开发者可自由继承并修改原型方法 备注: data 初始化也应可配置 目前内置的是shallowref 无法监听深层变动 另外建议:目前源码采用了插件化的代码组织模式,但是在构建发布npm后 ,只有汇总的文件。可以参考dayjs等优秀库的方式 所有资源分开编译打包上传后 开发者自由选择和注册需要的插件 尽量做到引入资源最小化。当然这个库本身并不大 但可以做到更好
### formatResult 方法 希望把 1.x 版本的 formatResult 方法加回来,感觉这个方法挺实用也挺好用的
### Bug 描述 Bug description 配置是这样的  数据是这样的  本来应该是 5却得到 1  我自己用 lodash get 得到的值是对的 ### 代码重现 Reproduce ### 期望结果 Desired result 期望是 5 ### 其他信息 Other information
### 需求描述 Feature Description 由于ready在 false → true 时会自动发出请求, 如果和refreshDeps共同使用,这将会同时发出两次请求 例如 ```js const val = ref() setTimeout(() => val.value = 'hello', 1000) setTimeout(() => val.value = 'world', 2000) useRequest(foo, {...
### 需求描述 Feature Description vue-request拥有插件plugins的设计,但是在官网中没有相应的文档。
custom plugin supports adding custom parameters in `options`,example: ``` declare module 'vue-request' { interface PluginOptions { customParameters?: Ref } } const useReadyPlugin = definePlugin((queryInstance, { customParameters = ref(true),// ...otherOptionsParameters })...
### 问题描述 Problem Description createQuery设计的initialState参数,实际调用该函数时,initialState参数丢失 在此处定义vue-request\src\core\createQuery.ts ``` const createQuery = ( service: Service, config: Options, initialState?: UnWrapRefObject, ): Query ``` 使用vue-request\src\core\useQuery.ts ``` function useQuery( service: Service, options: Options = {},...
### 问题描述 Problem Description useRequest 函数执行后返回的 data 不是 shallowRef 吗,是文档写的不对吗 版本:2.0.4 文档上写的是:https://www.attojs.com/api/#data data 类型: shallowRef 默认值: undefined 接口返回的数据。 并且 node_modules 里面的 index.d.ts 中定义的 type State = { loading: Ref; data:...
### 需求描述 Feature Description 在接口调用前,例如onBefore中,return true则调继续用接口,return false则停止调用接口,这样就能把接口调用前的提示弹窗写在里面,提高控制性,使用代码逻辑更清晰
### 问题描述 Problem Description 我一个页面参数会变,参数变化后需要重新请求,且确保旧的数据要清空,目前我这样做,总是报类型错误 ``` const { data, error, loading, run, cancel, mutate } = useRequest(GetMarketStatusBinding, { defaultParams: [ { market: 1, accountId: '', }, ], }); const reset...