物料ui自动完成输入值为空

时间:2020-06-04 14:12:15

标签: css reactjs material-ui react-material

我在项目中使用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" />
    }}
/>

enter image description here

我的package.json值:

"@material-ui/core": "4.3.1",
"@material-ui/icons": "4.2.1,
"@material-ui/lab": "4.0.0-alpha.35"

0 个答案:

没有答案