[英]how to get click event on list (autocomplete) in react?
I am trying to make auto-complete multi-select in react .我正在尝试在 react 中进行自动完成多选。 But when
a
in input it shows me filtered list ,Now I want to get an event when I select any item from list
但是,当
a
输入它显示我的过滤列表,现在我想,当我选择任何项目获得的事件list
is there any way to get an event when user selects an item from the list with it's selected value当用户从列表中选择具有选定值的项目时,是否有任何方法可以获取事件
https://codesandbox.io/s/semantic-ui-react-example-7iy8l https://codesandbox.io/s/semantic-ui-react-example-7iy8l
API LINK https://react.semantic-ui.com/modules/dropdown/#types-clearable-multiple API 链接https://react.semantic-ui.com/modules/dropdown/#types-clearable-multiple
<Dropdown
clearable
fluid
multiple
search
selection
options={countryOptions}
placeholder='Select Country'
/>
You can listen to the onChange
event on Dropdown
and get the last item of the value
array可以在
Dropdown
上监听onChange
事件,获取value
数组的最后一项
<Dropdown
onChange={(e, { value }) => console.log(value[value.length - 1])}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.