簡體   English   中英

Bootstrap 5 模態在 Electron 中不起作用

[英]Bootstrap 5 Modal not working in Electron

我在我的 web 應用程序中使用引導程序 5,但模式未顯示。

這是我的模態和激活它的按鈕的 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"
        />

這里是 typescript 代碼,它指定了 bootstrap-5 提供的通過 js 打開模式的代碼。

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

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

任何幫助都是好的,因為我今天已經完成了調試。

引導模式 v5用法

要么你必須使用data-屬性:

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

或通過腳本:

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

編輯:還有

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

只是顯示模式時的事件監聽器(顯示轉換結束后)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM