【发布时间】:2021-10-07 20:08:27
【问题描述】:
我在我的 react 应用程序中使用材料 UI 的自动完成功能,我想在更改项目时获取值,但我变得未定义。
这是我的代码
<Controller
name="partnerId"
control={control}
defaultValue={[]}
render={({ field: { onChange, value } }) => (
<Autocomplete
id="filter-demo"
className="mt-8 mb-16"
defaultValue={personObj}
value={value}
onChange={(newValue) => {
console.log('value...', newValue)
onChange(newValue);
}}
variant="outlined"
options={partners}
getOptionLabel={option => option.name}
filterOptions={filterOptions}
renderInput={params => <TextField {...params} label="Partners" variant="outlined" />}
/>
)}
/>
【问题讨论】:
标签: reactjs react-native autocomplete material-ui