【发布时间】:2021-03-14 07:44:57
【问题描述】:
我在自动完成建议中显示来自 state 的三个属性值(option.primary_line、option.city、option.state 和 option.zip_code); however, I'm trying to display only the option.primary_line value in the textarea when an option from the list is selected.我尝试将 option.primary_line 值设置为 state 并将其作为值(也尝试过 defaultValue)添加到 textarea 中,但无济于事。我错过了什么?
<Autocomplete
id="combo-box-demo"
options={addressSuggestions}
getOptionLabel={(option) =>
`${option.primary_line}, ${option.city}, ${option.state} ${option.zip_code}`
}
onInputChange={handleAddressLookup}
freeSolo={true}
renderInput={(params) => (
<TextField
{...params}
variant="outlined"
fullWidth
/>
)}
/>
【问题讨论】:
标签: reactjs react-hooks material-ui