Closed Locter9001 closed 4 months ago
ProFormSelect 中传递了默认值,但没有渲染在显示区域中,并且显示区域是空的,连占位符都没有显示,这说明可能有值但没有被正确渲染
运行代码
正确设置初始值
import { GetCategories } from '@/services/api/category'; import { SelectOptionType } from '@/typings'; import { ProFormSelect, ProFormSelectProps } from '@ant-design/pro-components'; import { BaseOptionType } from 'antd/es/select'; import React from 'react'; const ProformSelectCategory = <T, OptionType extends BaseOptionType = any>( props: ProFormSelectProps<T, OptionType>, ): React.ReactElement => { const fetchCategoryList = async ({ keyWords }: { keyWords: string; }): Promise<SelectOptionType[]> => { // if (!keyWords) return []; console.debug('<ProformSelectCategory> 搜索的关键字: ', keyWords, props.initialValue); try { const data = await GetCategories(); return data.map((it): SelectOptionType => { return { label: it.name!, value: it.id!, key: it.id }; }); } catch (e) { console.debug('没有找到该分类'); return []; } }; return ( <ProFormSelect<T, OptionType> fieldProps={{ labelInValue: true, }} {...props} request={fetchCategoryList} /> ); }; export default ProformSelectCategory;
当前 Issue 未检测到标题,请规范填写,谢谢!
The title of the current issue is not detected, please fill in according to the specifications, thank you!
🐛 bug 描述
ProFormSelect 中传递了默认值,但没有渲染在显示区域中,并且显示区域是空的,连占位符都没有显示,这说明可能有值但没有被正确渲染
📷 复现步骤 | Recurrence steps
运行代码
🏞 期望结果 | Expected results
正确设置初始值
💻 复现代码 | Recurrence code
© 版本信息
🚑 其他信息