[英]react-select - onInputChange event doesn't records the selected option's value, then how to get it?
According to the async example on the component's doc, the onInputChange
event only records the value you type, but once you select an option, everything is cleared. 根据组件文档上的异步示例, onInputChange
事件仅记录您键入的值,但是一旦您选择了一个选项,便会清除所有内容。
I think the aim should instead be to get the selected value... 我认为目标应该是获得选定的价值...
I have tried to find another event that will return the selected value, but I still don't get it. 我试图找到另一个将返回所选值的事件,但是我仍然不明白。 Curiously none of the examples touches that aspect ... 奇怪的是,这些例子都没有涉及到这一方面。
Please how can I retrieve the selected option ? 请问我如何找回选择的选项? Note that I am using v2
请注意,我正在使用v2
@acmoune answered his own question in the comments, but I'm putting it in as an 'Answer', for those who find this question on SO later. @acmoune在评论中回答了他自己的问题,但对于那些后来在SO上找到此问题的人,我将其作为“答案”放入。
The React-Select onChange
event is fired when an option is selected. 选择一个选项时会触发React-Select onChange
事件。 You can use this to get the 'selected' value. 您可以使用它来获取“选定”值。 This is outlined in the StateManager Props section of the React-Select documentation. React-Select文档的StateManager道具部分对此进行了概述。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.