首页 > 解决方案 > 选择 2 中没有可见的垂直滚动条

问题描述

我将 select 2 4.0.6-rc.0 与 bootstrap 4.3 一起使用

<div class="row option-select">
      <div class="col-sm-6 country-col">
      <select id="selection" class="custom-select custom-select-sm">
      </select>
    </div>
  </div>

我正在通过 ajax 获取数据。一切正常,除了选择显示 5 个选项并且没有滚动条,因此即使有超过 10 个选项,我也无法查看更多选项。

<script type="text/javascript">
            $(document).ready(function() {
       $('#selection').select2({

        ajax: {
          url: './data/c-list.php',
          type: 'post',
          dataType: 'json',
          delay: 250,
          data: function (params) {
            return {
              searchTerm: params.term
            };
          },
          processResults: function(response) {
            return {
              results: response
            };
          },
          cache: true
        }
});

});

标签: jqueryjquery-select2

解决方案


推荐阅读