我有一个表格,在最后一列中有以下下拉列表:
<td>
<div>
<button aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" id="dropdownMenu2" type="button">Dropdown</button>
<div aria-labelledby="dropdownMenu2">
<button type="button">Action</button> <button type="button">Another action</button> <button type="button">Something else here</button>
</div>
</div>
</td>
当我点击下拉菜单时它没有打开,可能是什么问题?
会不会是aria
和data
属性引起的?
最佳答案
我认为 className 属性在这里不起作用。如果您将“className”替换为“class”并仅添加 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>
关于html - 下拉 react 不适用于 Bootstrap v4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44290229/