模态内容不显示在下拉列表中

Modal content don't show in dropdown

我正在从下拉菜单中调用 Bootstrap 5 模式,但它没有显示内容,而是仅显示灰色背景。我缺少什么?

这是jsfiddle,这是代码:

<div class="container">
  <div class="row">
    <div class="inline-block">
      <div class="dropdown">
        <button type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="btn btn-primary">Dropdown</button>
        <ul class="dropdown-menu dropdown-menu-end">
          <li>
            <button type="button" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#test">
              Launch demo modal
            </button>

            <div class="modal fade" id="test" tabindex="-1">
              <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">
                    ...
                  </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>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>

模态代码应该在<ul>标签之外

<div class="container">
  <div class="row">
    <div class="inline-block">
      <div class="dropdown">
        <button type="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="true" class="btn btn-primary">Dropdown</button>
        <ul class="dropdown-menu dropdown-menu-end">
          <li>
            <button type="button" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#test">
                Launch demo modal
              </button>

          </li>
        </ul>
      </div>
    </div>
  </div>

  <div class="modal fade" id="test" tabindex="-1">
    <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">
          ...
        </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>
</div>