我有桌子,在最后一栏我下拉了:
<td>
<div className="dropdown">
<button className="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</button>
<div className="dropdown-menu" aria-labelledby="dropdownMenu2">
<button className="dropdown-item" type="button">Action</button>
<button className="dropdown-item" type="button">Another action</button>
<button className="dropdown-item" type="button">Something else here</button>
</div>
</div>
</td>
但是当我点击下拉列表时它没有打开,可能是aria和数据属性有问题吗?
答案 0 :(得分:0)
我不认为className属性在这里工作。如果你替换&#34; className&#34; by&#34; class&#34;并且只需添加bootstrap即可。
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
</head>
<body>
<td>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenu2">
<button class="dropdown-item" type="button">Action</button>
<button class="dropdown-item" type="button">Another action</button>
<button class="dropdown-item" type="button">Something else here</button>
</div>
</div>
</td>
</body>
</html>
答案 1 :(得分:0)
我有类似的问题。将脚本文件(bootstrap,jquery等)从文件底部移动到<head>
引导程序下拉列表开始工作。