小编dok*_*tih的帖子

使用 material-ui 自动完成获取所选值的“ID”

我正在使用带有 material-ui 的自动完成组件。

  1. 搜索字段中“customerList”中的数据没有问题。但是我无法获得我选择的数据的“ID”号。我想获取所选数据的 ID 号。

  2. 此外,会出现如下错误。我怎样才能解决这个问题?

在此处输入图片说明

import Autocomplete from '@material-ui/lab/Autocomplete';


class AppointmentFormContainerBasic extends React.PureComponent {
  constructor(props) {
    super(props);
  }

  render() {

    const textEditorProps = (field) => ({
      variant: 'outlined',
      onChange: ({ target: change }) => this.changeAppointment({
        field: [field], changes: change.value
      }),
      value: displayAppointmentData[field] || '',
      className: classes.textField
    });

    const customerList = [
      {id: "1", customerName: 'John', customerSurname: "test0"},
      {id: "2", customerName: 'Bob', customerSurname: "test1"},
      {id: "3", customerNametle: 'steve', customerSurname: "test2"},
      {id: "4", customerName: 'steve', customerSurname: "test3"},
      {id: "4", …
Run Code Online (Sandbox Code Playgroud)

javascript autocomplete reactjs material-ui

4
推荐指数
1
解决办法
4041
查看次数

标签 统计

autocomplete ×1

javascript ×1

material-ui ×1

reactjs ×1