Skip to content
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

如何在modelA里访问modelB的数据? #18

Open
linzeguang opened this issue Jun 9, 2022 · 4 comments
Open

如何在modelA里访问modelB的数据? #18

linzeguang opened this issue Jun 9, 2022 · 4 comments

Comments

@linzeguang
Copy link

如题

@linzeguang
Copy link
Author

是不是?store.getState()?

@geekact
Copy link
Member

geekact commented Jun 9, 2022

导入即可使用

import { modelB } from './modelB';

export const modelA = defineModel('a', {
  effects: {
    foo() {
      this.state;
      modelB.state;
    },
  }
});

@geekact
Copy link
Member

geekact commented Jun 9, 2022

是不是?store.getState()?

modelB.state === store.getState()[modelB.name]

直接从store拿没有类型提示,而且不能用于 computed 计算属性,不推荐这么用

@linzeguang
Copy link
Author

是不是?store.getState()?

modelB.state === store.getState()[modelB.name]

直接从store拿没有类型提示,而且不能计算计算属性,不推荐这样用

1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants