反应材质ui自动完成挂钩

问题描述:

我在react中使用了实质性的UI自动完成功能,并且工作正常.

I'm using the material UI autocomplete in react and it's working fine.

但是,我不知道如何获取所选项目的对象.例如,我想搜索一个人,然后将该项目添加到对象数组和表中.人员对象,包括姓名,电子邮件等.

However, I can't figure out how to get the object of the selected item. Ex I want to search for a person and then add that item to an array of objects, and into a table. The person object including name, email and so on.

而且我似乎找不到任何示例.

And I can't seem to find any examples of this.

我的代码如下: 我的代码

我正在尝试: https://material-ui.com/components/autocomplete/

有人对此有一个想法吗?我很新来做出反应.

Does anyone have an Idé on how to do this? I'm pretty new to react.

您可以使用自动完成功能的onChange属性,并在选项数组中按ID查找对象.

You can use onChange property of Autocomplete and find object by id in the array of options.