ant design pro 使用 getFieldValue、setFieldsValue
getFieldValue
获取表单指定 name
值,setFieldsValue
为表单指定 name
设定值
import type { ProFormInstance } from '@ant-design/pro-components';
const CreateDictForm: React.FC<CreateFormProps> = (props) => {
// 创建一个ref
const ref = useRef<ProFormInstance>();
const renderContent = () => {
return (
<ProForm formRef={ref}>
<ProFormSelect
name="configName"
fieldProps={{
onChange: (val: any) => {
// name 为 form name
const name = ref.current?.getFieldValue({ name: 'name' })
// configName 为 form configName
ref.current?.setFieldsValue({ configName: undefined });
},
}}
/>
</ProForm>
);
};