getOptionLabel返回一个字符串,有没有一种方法可以返回jsx元素,这将增加自定义。
当前: This doesn't has the airportNames it only has the iata code and operation city
所需: This contains the AirportNames and it has iata code and the operation city
PS:我的api中有机场名称,我只需要一种方法就可以做到这一点,我可能建议将我的JSX元素传递给自动完成API中的getOptionLabel属性,但这只需要字符串
const defaultProps = {
options: list,
getOptionLabel: (option) => `${option.iata} (${option.cityServed})`,
};
return(
<div className={classes.SourceDestination}>
<div className={classes.Source}>
<Autocomplete
{...defaultProps}
className="AirportSelectTextAuto"
openOnFocus
id="Source"
value={Source}
onChange={(event, newValue) => {
setSource(newValue);
textInput.current.focus();
getSource(newValue)
}}
renderInput={(params) => <TextField className="AirportSelectText" {...params} label="Source" margin="normal" />}
/>
</div>
)```