我有时在我的 html 页面中遇到问题,其中 bootstrap-select 中的所有选项都显示在下拉框之外。(附上截图)下拉
有时仅观察到此问题。这些值是从 api 调用中填充的。这是我的引导选择 css 和 js 参考: https : //cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css,https://cdnjs.cloudflare .com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.js
下面是我的代码片段。
$.ajax({
url: serverName + "api/v1/get/countrylist",
type: 'GET',
headers: {
"Content-Type": "application/json",
"Authorization": "Basic " + basicKey,
"x-access-token": xAccessToken
},
success: function(response){
// console.log("visa-response: "+ response);
var countryArr = [];
response.forEach(function(item){
countryArr.push({"country": item.country, "fee": item.fee});
// console.log("my country " + item.country)
})
//console.log("countryArr-response: "+ countryArr[1].country);
countryArr.forEach(function(item){
$('.select-country .country-list').append('<option class="'+item.fee + '"' +'data-tokens="'+ item.country+'">' + item.country +'</option>')
})
$('.selectpicker').selectpicker();
},
error: function (exception) {
console.log(exception);
}
});
<div class="col-md-6 select-country">
<div class="customer-country text-center" >
<label style="margin-right:10px;"><strong>Select Your Country:</strong></label>
<select class="selectpicker country-list" data-live-search="true" data-width="auto" data-style="btn-success" data-dropup-auto="false" standard title="Select Country...">
</select>
</div>