ice3项目设置了rootId后作为子应用仍会挂载到默认的#ice-container根节点上
Describe the bug
ice3项目作为子应用,在app.tsx中设置了app.rootId,添加@ice/plugin-icestark依赖并添加对应配置,作为子应用启动后,看到子应用仍挂载在#ice-container下,而不是自定义的app.rootId下
Expected behavior
期望子应用挂载在app.rootId下
Actual behavior
No response
Version of ice.js
3.2.5
Content of build.json or ice.config.mts
Additional context
No response
子应用渲染位置受主应用控制,如果主应用有特殊逻辑可以参考 https://github.com/alibaba/ice/blob/ace5e1dd155d4fcaa20aa28c4b328ad5dd800d46/packages/plugin-icestark/src/index.ts#L47-L68
子应用渲染位置受主应用控制,如果主应用有特殊逻辑可以参考
ice/packages/plugin-icestark/src/index.ts
Lines 47 to 68 in ace5e1d
export async function mount(props) { await app?.icestark?.mount?.(props); // Avoid remount when app mount in other micro app framework. if (!root) { // When app mount in qiankun, do not use props passed by. // Props of container if conflict with render node in ice, it may cause node overwritten. let runtimeOptions = props; if (props.singleSpa) { const iceContainer = props.container?.querySelector('#ice-container'); if (iceContainer) { runtimeOptions = {...props, container: iceContainer }; } else { const ele = document.createElement('div'); ele.id = 'ice-container'; props.container.appendChild(ele); runtimeOptions = {...props, container: ele }; } } root = render({ runtimeOptions }); } await root; }
你的意思是,48行的代码中调用的mount方法,来源于业务自定义的mount逻辑,我可以在那里自定义作为子应用时挂载到某根节点的逻辑? 另外我确实在主应用中使用了qiankun作为微应用框架,我先前定位到问题可能出现在54到64的if分支逻辑,在该分支内硬编码了根节点为#ice-container,而没有使用ice3子应用的app.rootId。