实现界面
<Col span={12}><ProForm.Itemname="name"label="推荐用户"><AutoCompleteclassName="pro-field pro-field-md"placeholder="请输入用户名"options={NameArr}onSearch={debounce(searchUser, 500)}onSelect={onSelect}/></ProForm.Item></Col>
//查询用户const searchUser = async (searchText: string) => {dispatch<UserAction>({type: 'user/check',payload: { keyword: searchText },});}const onSelect = (data: string) => {const nameitem = checkarr?.find(({ id }) => id === data)if (!nameitem) returnconst { name } = nameitemformRef?.current?.setFieldsValue({name});setparentUserId({data})};useEffect(() => {setNameArr((checkarr || []).map(({ id, name }) => ({value:id,label: `${name}`})))}, [checkarr])
formRef?.current?.setFieldsValue({name });目的为了设置选择后的value,而不是展示选择的id