-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Need Help]v2的两个优化问题 #134
Comments
下个版本会导出来
自定义缓存可以实现,你只要自己去管理 cacheKey 即可。但你仍需要显式的传入 cacheKey,即使你不是用它,因为这是开启缓存的依据。 const store = {};
const key = "some key";
const { runAsync } = useRequest(getUser, {
cacheKey: key,
manual: true,
setCache: (_, d) => {
store[key] = d;
},
getCache: () => {
return store[key];
},
}); |
setCache 和 getCache 怎么才能拿到runAsync的入参。 |
这需要 |
好的,我临时在公共请求里自己封装了一层cache希望能迭代到v2版本中,非常感谢 |
rc 版本已支持 |
这个问题我们已经在 v2 版本处理了,目前 v2 版本已经发布 rc 版本。 欢迎试用。 文档:https://next.attojs.com 安装最新版本 $ npm install vue-request@next
# or
$ yarn add vue-request@next
# or
$ pnpm install vue-request@next |
|
这个问题之前会回复过了 #121 (comment) |
v2的两个俩问题
1.index.d.ts 里面的 type Options 能不能导出 便于引用 二次封装自己请求函数。
2.缓存时现在是完全基于的cacheKey 进行缓存 我想基于cacheKey加请求参数去做缓存 应该怎么搞,用自定义的setCache 方法可以实现么,主要使用场景是 三级联动选择框组件,初始化时请求同一个接口,但是父级id不一样 我现在是manual设置为true 然后依次调用三次runAsync({id:praentId}),因为设置了是同一个封装request方法同一个cacheKey,结果拿到的数据从缓存取了。
Originally posted by @yuntian001 in #121 (comment)
The text was updated successfully, but these errors were encountered: