简体   繁体   English

Bootstrap 5 模态在 Electron 中不起作用

[英]Bootstrap 5 Modal not working in Electron

I'm using bootstrap 5 in my web app and the modal is not showing up.我在我的 web 应用程序中使用引导程序 5,但模式未显示。

Here is the HTML for my modal and for the button activating it:这是我的模态和激活它的按钮的 HTML:

<div
          class="modal"
          tabindex="-1"
          id="newInstallModal"
          aria-labelledby="settings"
        >
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <h5 class="modal-title">Modal title</h5>
                <button
                  type="button"
                  class="btn-close"
                  data-bs-dismiss="modal"
                  aria-label="Close"
                ></button>
              </div>
              <div class="modal-body">
                <p>Modal body text goes here.</p>
              </div>
              <div class="modal-footer">
                <button
                  type="button"
                  class="btn btn-secondary"
                  data-bs-dismiss="modal"
                >
                  Close
                </button>
                <button type="button" class="btn btn-primary">
                  Save changes
                </button>
              </div>
            </div>
          </div>
        </div>
        <input
          id="newInstallButton"
          type="button"
          class="btn btn-outline-primary"
          value="New Install"
        />

And here is the typescript code assigning that bootstrap-5 provided to open the modal via js.这里是 typescript 代码,它指定了 bootstrap-5 提供的通过 js 打开模式的代码。

newInstallModal = <HTMLDivElement>document.getElementById("newInstallModal");
newInstallButton = <HTMLButtonElement>document.getElementById("newInstallButton");

newInstallModal.addEventListener("show.bs.modal", () => {
   newInstallButton.focus();
})

Any help is good, because I'm done debugging for today.任何帮助都是好的,因为我今天已经完成了调试。

Bootstrap-modal v5 usage :引导模式 v5用法

Either you have to use data- attributes:要么你必须使用data-属性:

<button type="button" data-bs-toggle="modal" data-bs-target="#newInstallModal">Launch modal</button>

OR via script:或通过脚本:

var myModal = new bootstrap.Modal(document.getElementById('newInstallModal'), options)

EDIT: Also编辑:还有

myModal.addEventListener('shown.bs.modal', ...)

is just an eventlistener for when the modal is shown (after show transition ended)只是显示模式时的事件监听器(显示转换结束后)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM