将 enter select 设置为现有或最佳匹配项

Make enter select existing or top match

我们已经为我们的搜索实现了 algolia,但现在我们正试图弄清楚如何触发 "enter" 到 select 现有匹配项(假设您已完成输入并且它是一个匹配项),或者来自下拉列表的第一个 selected 选择。

我找不到任何关于此的好文档。有人知道怎么做吗?

示例(这里我希望点击进入时选择0934):

我认为您只是在寻找 autocomplete.jsautoselect parameter

autoselect – If true, pressing ENTER in the search bar will automatically select the first suggestion.

我猜,根据你的问题,你之后已经处理了选择事件,但如果你没有,或者其他人会偶然发现这个问题,接下来要做的是使用autocomplete:selected event 使用此选择(例如重定向或更改页面上的某些内容)。