折叠导航栏汉堡包无响应

Collapse navbar hamburger non responsive

我的导航栏折叠但在折叠后单击它时没有响应。我什至从 bootstrap docs(在隐藏品牌区域下)复制并粘贴了导航栏折叠代码,尽管在网站。

Navbar.ejs

<nav class="navbar sticky-top navbar-expand-lg navbar-dark" style="background-color: #00305a;">
  <div class="container-fluid">
      <a class="navbar-brand" href="#">MyBrand</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup"
      aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
  </button>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
    <div class="navbar-nav">
        <a class="nav-link active" href="#">Home</a>
        <a class="nav-link active" href="/events">Events</a>
        <a class="nav-link active" href="/artists">Artists</a>
    </div>
    <div class="navbar-nav ms-auto">
      <% if(currentUser) {%> 
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle text-white" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Profile
          </a>
          <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
            <li><a class="dropdown-item" href="/artists/<%=currentUser.id%>">View</a></li>
            <li><a class="dropdown-item" href="/artists/<%=currentUser.id%>/edit">Edit</a></li>
            <li><a class="dropdown-item" href="/logout">Logout</a></li>
          </ul>
        </li>  
        <%} else { %> 
          <a class="nav-link active" href="/login">Login</a>
          <a class="nav-link active" href="/artists/new">Sign Up</a>
        <% } %>
      </div>
    </div>
  </div>
</nav>

Boilerplate.ejs

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MacroTickets</title>

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bs-custom-file-input/dist/bs-custom-file-input.js"></script>

    <script src='https://api.mapbox.com/mapbox-gl-js/v2.4.1/mapbox-gl.js'></script>
    <link href='https://api.mapbox.com/mapbox-gl-js/v2.4.1/mapbox-gl.css' rel='stylesheet' />
    <link rel="stylesheet" href="/stylesheets/app.css">

    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap" rel="stylesheet">


    <script src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.7.2/mapbox-gl-geocoder.min.js"></script>
    <link rel="stylesheet" href="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.7.2/mapbox-gl-geocoder.css" type="text/css">

    <script src="https://unpkg.com/dayjs@1.8.21/dayjs.min.js"></script>
    <script>dayjs().format()</script>

</head>

我做错了什么?

您似乎在调用 Bootstrap 5,但在菜单本身中使用了 Bootstrap 4 代码。例如,在靠近顶部的 button class="navbar-toggler" 中...

data-toggle="collapse" data-target="#navbarNavAltMarkup" 适用于 BS4。

对于 BS5,它需要阅读 data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup"