为什么切换按钮在Bootstrap 5导航栏上不起作用

ldfqzlk8  于 2023-03-16  发布在  Bootstrap
关注(0)|答案(1)|浏览(153)

我在Bootstrap 5中有一个导航栏,当我缩小屏幕时,切换按钮什么也不做。正如this question中最上面的答案所说,你必须使用data-bs-toggle,我也是。这个网站上没有问题可以解决我的问题。
这是我的导航栏,包括我如何将 Bootstrap 和其他需要的东西包含到我的应用程序中。

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>

<nav class="navbar navbar-expand-md justify-content-md-center justify-content-start" data-bs-theme="dark" style="background-color: #697184;">
        <button class="navbar-toggler ml-1" type="button" data-toggle="collapse" data-target="#collapsingNavbar2">
                  <span class="navbar-toggler-icon"></span>
              </button>
        <div class="navbar-collapse collapse justify-content-between align-items-center w-100 " id="collapsingNavbar2">
          <ul class="navbar-nav mx-auto text-md-center text-left">
            <li class="nav-item">
              <a class="nav-link" href="/"><strong>HOME</strong></a>
            </li>
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                              <strong>AMENITIES</strong>
                          </a>
              <ul class="dropdown-menu">
                  <li><a class="dropdown-item" href="/amenities/socialdeck">Social Deck</a></li>
                  <li><a class="dropdown-item" href="/amenities/tenniscourts">Tennis Courts</a></li>
                  <li><a class="dropdown-item" href="/amenities/pool">Pool</a></li>
                  <li><a class="dropdown-item" href="/amenities/playground">Playground</a></li>
                  <li><a class="dropdown-item" href="/amenities/basketballpickleball">Basketball & Pickleball Court</a></li>
                  <li><a class="dropdown-item" href="/amenities">Overview</a></li>
              </ul>
            </li>
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            <strong>RESOURCES</strong>
                          </a>
              <ul class="dropdown-menu">
                <li><a class="dropdown-item" href="/arc">Architectural Review Committee</a></li>
                <li><a class="dropdown-item" href="/closinginformation">Closing Information</a></li>
                <li><a class="dropdown-item" href="/residents">Resident Directory</a></li>
                <li><a class="dropdown-item" href="/sitemap">Sitemap</a></li>
              </ul>
            </li>

            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                              <strong>HOA</strong>
                            </a>
                <ul class="dropdown-menu">
                    <li><a class="dropdown-item" href="https://sixes.cincwebaxis.com/" target="_blank">Pay Dues</a></li>
                    <li><a class="dropdown-item" href="/boardmembers">Meet the Board</a></li>
                    <li><a class="dropdown-item" href="/covenantsbylaws">Covenants & Bylaws</a></li>
                    <li><a class="dropdown-item" href="/meetingminutes">Meeting Minutes/Financials</a></li>
                </ul>
              </li>

            <li class="nav-item">
              <a class="nav-link" href="/calendar"><strong>CALENDAR</strong></a>
            </li>
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                                <strong>CONTACT</strong>
                            </a>
                <ul class="dropdown-menu">
                  <li><a class="dropdown-item" href="/contact">Contact The Board</a></li>
                  <li><a class="dropdown-item" href="https://sixes.cincwebaxis.com/cinc/contact-us/" target="_blank">Contact Sixes Management Company</a></li>
                </ul>
              </li>
            <li class="nav-item">
              <a class="nav-link" href="/faq"><strong>FAQ</strong></a>
            </li>
          </ul>
          <ul class="navbar-nav ml-auto">
            <li class="nav-item">
                <a href="https://www.facebook.com/groups/1004130719643461/" target="_blank" class="nav-link"><i class="fa-brands fa-facebook fa-xl"></i></a>
            </li>
          </ul>
        </div>
      </nav>
      
          <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js" integrity="sha384-oBqDVmMz9ATKxIep9tiCxS/Z9fNfEXiDAYTujMAeBAsjFuCZSmKbSSUnQlmh/jp3" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js" integrity="sha384-mQ93GR66B00ZXjt0YO5KlohRA5SY2XofN4zfuZxLkoj1gXtW8ANNCe9d5Y3eG5eD" crossorigin="anonymous"></script>
webghufk

webghufk1#

要解决这个问题,我不仅要将data-toggle更改为data-bs-toggle,还要将data-target更改为data-bs-target

相关问题