0
点赞
收藏
分享

微信扫一扫

ant design pro 使用 getFieldValue、setFieldsValue

weipeng2k 2022-08-20 阅读 74

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



举报

相关推荐

0 条评论