首页 > 其他分享 >ant design pro 使用 getFieldValue、setFieldsValue

ant design pro 使用 getFieldValue、setFieldsValue

时间:2022-08-13 14:00:54浏览次数:59  
标签:const name getFieldValue setFieldsValue pro ref configName

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>
    );
  };

标签:const,name,getFieldValue,setFieldsValue,pro,ref,configName
From: https://www.cnblogs.com/niuben/p/16582912.html

相关文章