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

umimax + qiankun 如何在子应用监听 onGlobalStateChange 变化时 将state 通知到某个组件 #12218

Closed
lis-soft opened this issue Mar 19, 2024 · 1 comment

Comments

@lis-soft
Copy link

子应用 app.ts
image
想在监听到变化时,把最新的state放入子应用的全局数据流
vue 的实现方便可以store.commit
image
但是我使用Model 数据流的方式,不知道该怎么等价实现上面VUE的逻辑

@fz6m
Copy link
Member

fz6m commented Mar 20, 2024

你说的 “全局数据流” 是啥,是 umi 自带的那个 useModel 数据流吗,这个是 react 专用的。

如果是 vue 的话,你直接弄一个全局的响应式变量存这个数据就行,比如 reactive 、ref 、pinia 等等,注意失去响应式的问题,然后每次改这个响应式数据,子应用组件里这个值自己就变了,如果你想让数据在 react 和 vue 主子应用里都共享,最好自己做个总线方式订阅然后更新的方案。

@fz6m fz6m closed this as completed Mar 20, 2024
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