Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

qiankun的子应用中有使用到document获取dom元素的地方,但是嵌入到主应用中之后这个document是主应用的根节点不是希望的子应用的document,有什么解决方案吗?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
142 views
Welcome To Ask or Share your Answers For Others

1 Answer

假设你的子应用容器的 id 为 app-view

const appDocument = window.__POWERED_BY_QIANKUN__ ? window.document.querySelector('#app-view') : window.document

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...