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
怎么在组件外部获取store? #1491
Comments
request.js 是从 effect 调的,effect 可以拿到 state,然后传给 request.js。 |
那岂不是每次请求都要取一次token, 能不能在request.js里拿到token自动加上 |
不能,request.js 里不能直接取 state 。 |
@bowencool 你这种需求可以创建一个全局对象,自己来维护,需要管理的数据就是数据量小,但是使用频繁的。 |
@yvanwangl 多谢提醒 |
model中,effects中,怎么调用state呢??? |
@xiaofengqqcom123 |
可以通过app._store方式获取 |
ref: Dva 源码解析 | DvaJS |
这样获取呢,多看文档哈。 文档地址: |
https://umijs.org/plugins/plugin-dva#getdvaapp 用 getDvaApp() 来获取 getDvaApp()._store |
比如: 我想在
request.js
中拿到store
中的token
, 应该怎么做?我看
redux
文档是这么写的:可是
dva
创建的项目中, 这里的store
好像并没有经过我手...The text was updated successfully, but these errors were encountered: