我一直试图找出一种方法来选择"Enter“或",”击键时的提示,但找不到任何有关它的文档。此外,在编译过程中,我收到以下警告:" warning : react-bootstrap-typeahead selectHintOnEnter属性不推荐使用。在Hint组件上使用shouldSelect属性来定义哪些击键可以选择提示。“有没有关于如何在“提示”上使用shouldSelect的例子?
发布于 2020-05-31 02:20:44
shouldSelect属性具有以下签名:
(shouldSelect: boolean, SyntheticKeyboardEvent<HTMLInputElement>) => boolean您可以使用它来定义应在哪些条件下选择提示。在您的例子中,您需要类似于以下内容:
<Hint
shouldSelect={(shouldSelect, e) => {
// Select the hint if the user hits 'enter' or ','
return e.keyCode === 13 || e.keyCode === 188 || shouldSelect;
}}>
...
</Hint>下面是一个有效的示例:https://codesandbox.io/s/rbt-shouldselect-example-51s7n
https://stackoverflow.com/questions/62095090
复制相似问题