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

[Bug] qiankun 父应用如何给子应用同步数据。 #12006

Closed
consistent-k opened this issue Dec 27, 2023 · 4 comments
Closed

[Bug] qiankun 父应用如何给子应用同步数据。 #12006

consistent-k opened this issue Dec 27, 2023 · 4 comments

Comments

@consistent-k
Copy link
Contributor

consistent-k commented Dec 27, 2023

What happens?

使用官方这段代码进行父子应用通信,求问在父应用其他页面中,如何能调用这里的函数 将异步请求的数据设置给子应用。

Mini Showcase Repository(REQUIRED)

// src/app.ts
export function useQiankunStateForSlave() {
  const [globalState, setGlobalState] = useState<any>({
    slogan: 'Hello MicroFrontend',
  });

  return {
    globalState,
    setGlobalState,
  };
}

不明白如何再页面内调用这段。

How To Reproduce

按照umi文档操作

Context

  • Umi Version: 4.0.90
  • Node Version:18
  • Platform: macos
Copy link

由于缺乏足够的信息,我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2023
@fz6m
Copy link
Contributor

fz6m commented Dec 28, 2023

他本质上是一个 umi 中的数据流 model ,可以用 useModel('@@qiankunStateForSlave') 取到,然后修改,这个 model 是持久的。

@wuhanjun
Copy link

他本质上是一个 umi 中的数据流 model ,可以用 useModel('@@qiankunStateForSlave') 取到,然后修改,这个 model 是持久的。

如果子应用不是使用umi,怎么获取父应用数据的更新?子应用中监听onGlobalStateChange并没有触发

@fz6m
Copy link
Contributor

fz6m commented Feb 24, 2024

如果子应用不是 umi ,就使用 qiankun 原生的方法加载即可,和独立使用 qiankun 一个道理,比如用 loadMicroApp 加载子应用,然后在 props 里传给子应用数据,具体方法查看 qiankun 文档吧,这种情况就和 umi 无关了。

不想走 qiankun props 传递的话,或者通过全局总线做订阅更新也行。

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

3 participants