Bootstrap 选择器显示:Uncaught TypeError:无法设置未定义的属性“_menu”
2021-01-06
2051
我正在使用 bootstrap selectpicker,但每当我点击下拉列表时都会显示一些错误,并且我无法执行数据实时搜索,即使我更改了 bootstrap 版本但对我来说不起作用
链接:
<link rel="stylesheet" type="text/css" href="<?= base_url('assets/') ?>app-assets/css/bootstrap.css"> // Bootstrap v4.0.0-alpha.4
<link rel="stylesheet" href="<?= base_url() ?>assets/selectpicker/bootstrap-select.min.css"> // Bootstrap-select v1.13.12
<script src="<?= base_url('assets/') ?>app-assets/js/jquery.min.js"></script> // jQuery v3.3.1
<script src="<?= base_url() ?>assets/selectpicker/bootstrap-select.min.js"></script> // Bootstrap-select v1.13.12
<script src="<?= base_url('assets/') ?>app-assets/js/core/libraries/bootstrap.min.js" type="text/javascript"></script> // Bootstrap v4.0.0-alpha.5
带有数据实时搜索的下拉列表
<select class="selectpicker" data-live-search="true" data-hide-disabled="true" name="user" id="user">
<option value=''>option 1</option>
<option value=''>option 2</option>
<option value=''>option 3</option>
<option value=''>option 4</option>
<option value=''>option 4</option>
</select>
错误:
未捕获的 TypeError:无法在 bootstrap-select.min.js 中设置未定义的属性“_menu”
2个回答
尝试使用 CDN 链接代替 Bootstrap。效果非常好!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<title>Document</title>
</head>
<body>
<select
class="selectpicker"
data-live-search="true"
data-hide-disabled="true"
name="user"
id="user"
>
<option value="">option 1</option>
<option value="">option 2</option>
<option value="">option 3</option>
<option value="">option 4</option>
</select>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
</body>
</html>
Harman
2021-01-06
尝试使用相同 html 的此链接
<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>
mustafa abdelbadea
2021-01-06