简体   繁体   English

有很多选项时如何防止引导选择滚动冻结

[英]How to prevent bootstrap-select scroll from freezing when there are many options

I'm using a bootstrap-select with 1000 options.我正在使用具有 1000 个选项的引导选择

When I try to scroll down options, scroll goes down about 60 options and them it freezes in that place.当我尝试向下滚动选项时,滚动会向下滚动大约 60 个选项,然后它们会冻结在那个地方。

How can I fix it?我该如何解决?

My code:我的代码:

<select class="selectpicker" data-live-search="true">
      `<option> 0</option>
      <option> 1</option>
      <option> 2</option>
      <option>1000 more down</option>
</select>

I am not quite sure, but for me a selectpicker with 1000 elements is very bad because it is very difficult to find and select a certain option (bad UX).我不太确定,但对我来说,具有 1000 个元素的选择器非常糟糕,因为很难找到并选择某个选项(糟糕的 UX)。 In my own understanding, select-options should be limited to about ten or so, depending on the use-case of course.根据我自己的理解,选择选项应该限制在大约十个左右,当然这取决于用例。 I don't know the bootstrap-select library very well, however I would guess that the library as well as the select-tag are simply not designed to load so many options and generally need more memory to load so many.我不太了解 bootstrap-select 库,但是我猜想该库以及 select-tag 根本不是为了加载这么多选项而设计的,并且通常需要更多内存来加载这么多选项。

If you want to get a number as an input, I would highly recommend you to use an input of the type number instead.如果您想获得一个数字作为输入,我强烈建议您改用数字类型的输入。

 <!-- Bootstrap --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" /> <!-- Input --> <input type="number" class="form-control" min="0" max="1000" step="1" value="0">

If you don't only store numbers in your input, another possibility could be to create a sort of live-search where the user enters a text and only the items that match the most are displayed in a dropdown.如果您不仅在输入中存储数字,另一种可能性可能是创建一种实时搜索,用户在其中输入文本,并且只有最匹配的项目才会显示在下拉列表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM