在MUI自动完成中如何在选择选项后如何调用功能(不是同时)
执行后:
- 单击
自动完成
输入 - 在选项之间使用
arrow
按键 - 通过按
enter
键选择选项,
我想通过按下来调用功能再次输入
键,但我找不到如何做。
我尝试使用onkeydown
autocomplete
的输入,但通过在按下enter
上选择一个值,它也调用了该功能。
After doing:
- Clicking on
Autocomplete
input - Moving between options by using
arrow
keys - Selecting an option by pressing
enter
key
I want to call a function by pressing enter
key again but I cannot find out how to do it.
I tried to use onKeyDown
event on Autocomplete
's input but by selecting a value on pressing enter
it calls the function too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我找到了这个。
onChange
具有以下props:(事件:任何,值:字符串,原因:autocompleteinputchangeasean)
,一旦选择了建议原因>原因>原因
具有值重置
I found this.
onChange
has following props:(event: any, value: string, reason: AutocompleteInputChangeReason)
and once suggestion is selectedreason
has valuereset
您可以在MUI自动完成中使用Onchange Prop。喜欢:-
You can use onChange prop in MUI Autocomplete. like:-
我找到了要实现的此功能的解决方法:
我保留
iSopen
autocomplete
的状态,并使用 oncoce> onclose 和onopen < /code>要更改
等法的事件
并在输入中按密钥时,我检查键代码是否是Enter
和iSopen
ISfalse
然后我调用我想要的方法:I found a workaround for this feature I want to implement:
I keep an
isOpen
state for theAutocomplete
and useonClose
andonOpen
events to changeisOpen
and on pressing keys in the input I check if the key code isEnter
andisOpen
isfalse
then I call the method I want: