微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Bootstrap导航栏在暴民视图中不起作用,当我单击按钮时,下拉菜单未显示

如何解决Bootstrap导航栏在暴民视图中不起作用,当我单击按钮时,下拉菜单未显示

<nav class="navbar navbar-expand-lg mt-md-4 navbar-dark">
  <div class="container px-0">
    <a class="navbar-brand" href="#">
      <img src="./img/icon-assets/purple-tutor-logo.png" alt="" />
    </a>
    <button
      class="navbar-toggler custom-toggler"
      type="button"
      data-toggle="collapse"
      data-target="#navbarNav"
      aria-controls="navbarNav"
      aria-expanded="false"
      aria-label="Toggle navigation"
    >
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <div class="mr-auto"></div>
      <ul class="navbar-nav">
        <li class="nav-item" data-interval="3000">
          <a class="nav-link" href="#">Courses</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">About Us</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">How it Works</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">FAQs</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">School Registration</a>
        </li>
        <li class="nav-item">
          <a
            class="nav-link btn btn-lg btn-nav"
            href="https://study.purpletutor.com/register"
            >Get a FREE TRIAL!</a
          >
        </li>
      </ul>
    </div>
  </div>
</nav>

这是我的导航栏,有人可以告诉我什么错误是为什么在暴民视图中单击按钮时没有显示折叠菜单

这是我正在使用的脚本,我正在使用bootstrap 4 cdn,有人可以帮帮我吗,我已经检查了堆栈溢出的多个帖子

<script
  src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
  integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
  crossorigin="anonymous"
></script>
<script
  src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"
  integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV"
  crossorigin="anonymous"
></script>

解决方法

您的代码没有错误,您仅缺少用于移动设备的下拉列表中包含的jquery,请在引导脚本之前添加它,如下所示:

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script
  src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"
  integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
  crossorigin="anonymous"
></script>
<script
  src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"
  integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV"
  crossorigin="anonymous"
></script>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。