【问题标题】:Bootstrap collapse with accordion not workingBootstrap 崩溃,手风琴不起作用
【发布时间】:2020-10-28 10:24:59
【问题描述】:

我需要一个折叠和显示功能..

我的代码如下

<div class="accordion" id="Preview">
      <div class="card z-depth-0 bordered">
        <div class="card-header" id="headingOne2">
          <h5 class="mb-0">
            <button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne2"
              aria-expanded="true" aria-controls="collapseOne2">
              Collapsible Group Item #1
            </button>
          </h5>
        </div>
        <div id="collapseOne2" class="collapse" aria-labelledby="headingOne2"
          data-parent="#Preview">
          <div class="card-body">
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3
            wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum
            eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla
            assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred
            nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer
            farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus
            labore sustainable.
          </div>
        </div>
      </div>
      <div class="card z-depth-0 bordered">
        <div class="card-header" id="headingTwo2">
          <h5 class="mb-0">
            <button class="btn btn-link collapsed" type="button" data-toggle="collapse"
              data-target="#collapseTwo2" aria-expanded="false" aria-controls="collapseTwo2">
              Collapsible Group Item #2
            </button>
          </h5>
        </div>
        <div id="collapseTwo2" class="collapse" aria-labelledby="headingTwo2"
          data-parent="#Preview">
          <div class="card-body">
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3
            wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum
            eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla
            assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred
            nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer
            farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus
            labore sustainable.
          </div>
        </div>
      </div>
      <div class="card z-depth-0 bordered">
        <div class="card-header" id="headingThree2">
          <h5 class="mb-0">
            <button class="btn btn-link collapsed" type="button" data-toggle="collapse"
              data-target="#collapseThree2" aria-expanded="false" aria-controls="collapseThree2">
              Collapsible Group Item #3
            </button>
          </h5>
        </div>
        <div id="collapseThree2" class="collapse" aria-labelledby="headingThree2"
          data-parent="#Preview">
          <div class="card-body">
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3
            wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum
            eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla
            assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred
            nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer
            farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus
            labore sustainable.
          </div>
        </div>
      </div>
    </div>

但它不工作..按钮是这样来的..但没有折叠并显示卡内的数据。

[![image of output][1]][1]

悬停,一切正常,但没有崩溃。 [1]:https://i.stack.imgur.com/ndr4I.png

是什么原因?

【问题讨论】:

  • 你能在这里添加完整的html代码吗?您是否已将 boostrap 样式导入到 angular.json 文件中?
  • 这是手风琴的 html 代码..rest 只是一个 h4 标头。是的..我在 angular.json 中导入了引导程序,其他引导程序功能工作正常..这个手风琴的唯一问题
  • 为什么不使用 ng-bootstrap? ng-bootstrap accordion

标签: html angular bootstrap-4 accordion collapse


【解决方案1】:

我在头部运行了您的脚本,其中包含以下文件和脚本,它按预期工作。您可能缺少其中一个或没有最新版本?

# Bootstrap CSS
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

# Jquery
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>

# Bootstrap JS
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

【讨论】:

    猜你喜欢
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    • 2013-11-20
    • 1970-01-01
    • 2012-12-21
    • 2019-08-09
    • 1970-01-01
    • 2019-02-27
    相关资源
    最近更新 更多