我将 minLength 设置为 3,以在输入至少 3 个字符时触发建议列表。
但是当输入 1 个字符时,下拉菜单会打开。如何让它工作?
$('#remote .typeahead').typeahead(null, {
name: 'best-pictures',
display: 'value',
source: bestPictures,
minLength: 3
});
fiddle : https://jsfiddle.net/tomsx/bc6trhjk/
最佳答案
根据此处的文档 - https://github.com/corejavascript/typeahead.js/blob/master/doc/jquery_typeahead.md#api ,第一个参数是options,不能为空。
将其更改为以下,它应该可以工作,
$('#remote .typeahead').typeahead({minLength: 3}, {
name: 'best-pictures',
display: 'value',
source: bestPictures,
});
关于javascript - typeahead - minLength 触发建议列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52353713/