<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>插件</title>
<link rel="stylesheet" href="dist/css/bootstrap.min.css">
<script src="dist/js/jquery-3.2.1.min.js"></script>
<script src="dist/js/bootstrap.min.js"></script>
</head>
<body>
<!--按钮层begin-->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
弹窗
</button>
<button class="btn btn-danger btn-lg" data-toggle="modal" data-target="#danger">
这是一个测试按钮
</button>
<div id="danger">
这是内容
</div>
<!--按钮层end-->
<!--modal弹窗窗口-->
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span>×</span>
<span class="sr-only">关闭弹窗</span>
</button>
<h4 class="modal-tittle" id="modalLable">标题</h4>
</div>
<div class="modal-body">
慕课网
</div>
<div>
<button type="button" class="btn btn-default" data-dismiss="modal">
关闭
</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">
保存
</button>
</div>
</div>
</div>
</div>
</body>
</html>
原因在此:data-toggle="modal"同事具备绑定与解除功能,在关闭弹窗时,没发现modal弹窗板块。
解决方法:在测试div板块,添加class="modal"属性即可。