是否可以将容器传递/更改为诸如Dialog,Popper等重要的ui组件? (https://material-ui.com/api/dialog/)他们在document.body上渲染弹出窗口
目的是能够从影子dom内显示对话框
export default class MyWebComponent extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: "open" });
this.mountPoint = document.createElement("span");
this.mountPoint.className = "inner-app";
this.reactRoot = shadowRoot.appendChild(this.mountPoint);
}
connectedCallback() {
const jss = create({
...jssPreset(),
insertionPoint: this.reactRoot,
});
render(
<StylesProvider jss={jss}>
<SimpleDialogDemo />
</StylesProvider>,
this.mountPoint
);
}
}
customElements.define("my-web-commponent", MyWebComponent);