【问题标题】:Bootstrap Modal Not Firing引导模式未触发
【发布时间】:2016-08-14 22:27:49
【问题描述】:

我已经使用了模态框,但由于某种原因,我无法使用以下标记启动模态框...我直接从引导网站上得到了这个,但仍然没有启动...

 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" />
 <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />

 <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

<div id="myModal" class="modal fade" role="dialog">
    <div class="modal-dialog">

        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Modal Header</h4>
            </div>
            <div class="modal-body">
                <p>Some text in the modal.</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>

    </div>
</div>

当我点击我的按钮时,什么都没有发生……

【问题讨论】:

  • 您粘贴了带有样式链接的代码,您是否链接了引导程序的“.js”文件?

标签: css twitter-bootstrap modal-dialog bootstrap-modal


【解决方案1】:

只需将以下 2 个文件放入您的代码中即可。

<script   src="https://code.jquery.com/jquery-2.2.3.min.js"   integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo="   crossorigin="anonymous"></script>

<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

查看工作演示

http://plnkr.co/edit/0RCb4GjLu8TExvMk5koL?p=preview

【讨论】:

    【解决方案2】:

    在 html 中关闭 body 标记之前的最后添加:

    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
    

    【讨论】:

    • 请将此评论放入您的答案中。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2014-11-06
    • 1970-01-01
    • 2015-03-30
    • 1970-01-01
    • 2013-12-17
    • 2018-01-31
    • 1970-01-01
    • 2017-07-29
    相关资源
    最近更新 更多