[英]Mui autocomplete to act like mui select
Hi I am trying to create a component that acts like mui select with mui aoutcomplete.您好我正在尝试创建一个组件,其行为类似于 mui select 和 mui aoutcomplete。
I am having problems to store the values like it was on select.我在存储 select 上的值时遇到问题。
i want something like the example in select我想要类似 select 中示例的东西
<MenuItem value=414>JUST SOME TEXT I CAN SERACH IN</MenuItem>
you can use the renderOption
prop to specify a custom option rendering function. This function should return a MenuItem
component with the desired value.您可以使用
renderOption
指定自定义选项呈现 function。此 function 应返回具有所需值的MenuItem
组件。
<Autocomplete
options={options}
getOptionLabel={option => option.title}
renderOption={option => (
<MenuItem value={option.value}>{option.title}</MenuItem>
)}
renderInput={params => (
<TextField {...params} label="Select" variant="outlined" />
)}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.