[英]How do I show which item in the Menu List is selected with Material UI React?
[英]How do I access the index of a selected item in list using React and Material UI?
我需要传递 onChange 所选菜单项的索引,但不知道如何访问它。
const handleListChange = (e) => {
console.log('Item Index: ', e.target.key);
}
<TextField
select
label="Select item"
value={show}
onFocus={getListArray}
onChange={e => handleListChange(e)}
>
{listArray.map((value, index) =>
<MenuItem
key={index}
value={value.title}
>
{value.title}
</MenuItem>
)}
</TextField>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.