<link rel="stylesheet" href="../../../statics/plugins/bootstrap-select-1.13.10/dist/css/bootstrap-select.css" />
<script src="../../../statics/plugins/bootstrap-select-1.13.10/dist/js/bootstrap-select.js"></script>
如果没有设置选中项,默认选中第一个option。如设置了tiltle属性,则显示title属性内容,不会默认选中。
<select class="selectpicker" title="大魔王">....</select>
<select class="selectpicker" data-style="btn-info">...</select>
<select class="selectpicker" data-live-search="true">....</select>
添加“multiple ” 设置为多选,并且设置最多能选择2项 data-max-options=“2”
设置检索placeholder属性:data-live-search-placeholder=“搜索”
添加“全选/反选” 功能按钮 data-actions-box=“true”
<select class="selectpicker form-control" multiple data-max-options="2"></select>
<select class="selectpicker" multiple data-live-search="true" data-live-search-placeholder="搜索" data-actions-box="true">
<optgroup label="filter1">
<option>option1</option>
<option selected>option2</option>
<option>option3</option>
<option>option4</option>
</optgroup>
<optgroup label="filter2">
<option>option1</option>
<option>option2</option>
<option>option3</option>
<option>option4</option>
</optgroup>
<optgroup label="filter3">
<option>option1</option>
<option>option2</option>
<option>option3</option>
<option>option4</option>
</optgroup>
</select>
$('.selectpicker').selectpicker('val','mustard');
$('.selectpicker').selectpicker('val',['mustard','relish']);
$('.selectpicker').selectpicker('refresh');
// 在使用 vue.js的时候,赋值完成后刷新无效可以尝试延时刷新
setTimeout(function(){
$("#cellSelecters").selectpicker("refresh");
},1000)
$('.selectpicker').on('changed.bs.select',function(e){});