tea-design / tea-component

36 stars 6 forks source link

notification在qiankun子系统使用,被挂载到主系统 #24

Open guoqirong opened 1 year ago

guoqirong commented 1 year ago

image 子系统做了挂载节点配置,但不生效

xughv commented 1 year ago

React Devtools 看下 Provider 和组件获取到的属性值看看?

guoqirong commented 1 year ago

子系统打包后的用ng挂载的,是不是notification在ts里直接使用,识别不了ConfigProvider的配置呢?

xughv commented 1 year ago

Notification 和 Message 这种非 React 渲染流中的组件是读不到流中的配置的

guoqirong commented 1 year ago

那有没有单独修改Notification挂载组件的方法呢?

xughv commented 1 year ago

Tea 有一个全局的 setConfig() 方法,可以试试

guoqirong commented 1 year ago

能给个示例吗

xughv commented 1 year ago

移掉 ConfigProvider 中的 popupContainer 配置,在渲染前调用 setConfig

import { setConfig } from 'tea-component';

setConfig({ popupContainer: xxx })
xughv commented 1 year ago

但是其实在 ConfigProvider 首次设置的时候,也同步了全局配置,所以建议还是先看看为什么没取到,也可以到 node_modules 下源码调试看看

React Devtools 看下 Provider 和组件获取到的属性值看看?

guoqirong commented 1 year ago

image 显示div,看不出是哪里的

xughv commented 1 year ago

image 显示div,看不出是哪里的

记得右键能 save 成变量查看的

guoqirong commented 1 year ago

{ "value": { "popupContainer": "

", "locale": "zh-CN" }, "children": "" } image image 没有保存的功能,复制出来的值和看到的一样

xughv commented 1 year ago

Store as global variable 就能在 Console 查看了

guoqirong commented 1 year ago

image 这里拿到的是在子系统里的,但Notification没有获取到这个值

xughv commented 1 year ago

稍等,我调整一下这里取值方式打个包试试

xughv commented 1 year ago

这里从 Context 读确实会有点问题,准备新增 notification.config()message.config() 方法支持单独配置 popupContainer 等属性

guoqirong commented 1 year ago

好的,这个大概什么时候可以给出,是整个项目配置一次就可以吗?

xughv commented 1 year ago

是的 设置是全局的,这周会打个 @beta 包

guoqirong commented 1 year ago

大佬,这个@beta 包今天能给,还是要下周呢?

xughv commented 1 year ago

tea-component@2.7.9-beta.2

message.config({ popupContainer: () => document.querySelector("xx") });
notification.config({ popupContainer: () => document.querySelector("xx") });
guoqirong commented 1 year ago

你这个配置后,重新从tea组件引入要重新配置吗?我这边不配置不生效的,试了一下配成全局状态存储message和notification也不生效

xughv commented 1 year ago

引入的是同一份的话是不需要的

guoqirong commented 1 year ago

是同一份,当不生效啊

xughv commented 1 year ago
guoqirong commented 1 year ago

可以了,之前的导出从tea-component/lib,可能是这个造成的,谢谢大佬