从材料ui getOptionLabel提交自动完成组件

时间:2020-06-27 16:02:21

标签: reactjs autocomplete material-ui

这是我的组件

<Autocomplete
                id="dossier"
                name="dossier"
                options={DataComboBox}
                getOptionLabel={(option) => option.title}
                style={{ width: 300 }}
                renderInput={(params) => <TextField {...params} label="Référence du dossier" variant="outlined" />}
                />

const DataComboBox = [
  { title: 'The Shawshank Redemption', year: 1994 },
  { title: 'The Godfather', year: 1972 },
  { title: 'The Godfather: Part II', year: 1974 },
  { title: 'The Dark Knight', year: 2008 },
  { title: '12 Angry Men', year: 1957 },
  { title: "Schindler's List", year: 1993 },
  { title: 'Pulp Fiction', year: 1994 },

我想显示“标题”项并在表单验证后发布年份。

0 个答案:

没有答案