【问题标题】:bootstrap data-toggle collapse not working引导数据切换崩溃不起作用
【发布时间】:2020-04-18 01:57:57
【问题描述】:

我的这个 html 测试用例几乎完全取自 bootstrap 的示例,但是当我按下任何按钮时,不会显示 div。

Bootstrap 4 文件托管在本地,因为它是本地应用程序而不是 Web 应用程序。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link type="text/css" rel="stylesheet" href="css/bootstrap.css" />
        <script src="js/bootstrap.js"></script>
        <script src="js/jquery.js"></script>
        <script src="js/popper.js"></script>
    </head>
    <body>
        <p>
            <a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
            Link with href
            </a>
            <button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
            Button with data-target
            </button>
        </p>
        <div class="collapse" id="collapseExample">
            <div class="card card-body">
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
            </div>
        </div>
    </body>
</html>

哪里出错了?

【问题讨论】:

    标签: javascript html bootstrap-4


    【解决方案1】:

    你必须在jquery.js之后包含bootstrap.js

    【讨论】:

    • 您可能应该将脚本移出标题并移到正文标签内的底部
    猜你喜欢
    • 1970-01-01
    • 2013-06-17
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 2015-07-30
    • 1970-01-01
    • 1970-01-01
    • 2019-07-18
    相关资源
    最近更新 更多