我在项目中使用Material UI自动完成模块。选择一个选项后,输入为空白,并且在对象inputProps中,键“ value”为空的空字符串(如随附的屏幕截图所示)。我正在使用以下代码:
<Autocomplete
id="combo-box-demo"
options={[
{ title: 'The Shawshank Redemption', year: 1994 },
{ title: 'The Godfather', year: 1972 },
{ title: 'The Godfather: Part II', year: 1974 },
{ title: 'The Dark Knight', year: 2008 },
]}
getOptionLabel={(option) => option.title}
style={{ width: 300 }}
renderInput={(params) => {
console.log(params)
return <TextField {...params} label="Combo box" variant="outlined" />
}}
/>
我的package.json值:
"@material-ui/core": "4.3.1",
"@material-ui/icons": "4.2.1,
"@material-ui/lab": "4.0.0-alpha.35"