【问题标题】:Material UI - Change Dialog Container材质 UI - 更改对话框容器
【发布时间】:2021-02-16 06:42:44
【问题描述】:

是否可以将容器传递/更改为 Dialog、Popper 等材质 ui 组件? (https://material-ui.com/api/dialog/) 他们在 document.body 上渲染弹出窗口

目的是能够在shadow 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);

【问题讨论】:

    标签: reactjs material-ui


    【解决方案1】:

    是的,Dialog 支持 Modal 的所有属性,包括 container 属性。 Popper 也有一个 container 属性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-09-11
      • 2021-02-12
      • 2020-10-13
      • 2019-09-26
      • 1970-01-01
      • 2021-12-26
      • 2022-01-12
      相关资源
      最近更新 更多