如何帮网站,长长沙网站制作,wordpress ppt插件,wordpress自定义seo标题问题背景
我有两个表单项#xff0c;当我选择出库类型#xff0c;调用onChange改变inOutType 状态#xff0c;这时候发现这句代码不生效#xff1a;
rules{[{ required: true, message: 请选择${inOutType 1 ? 持有人 : 负责人} }]}示例代码
TypographyForm.Group…问题背景
我有两个表单项当我选择出库类型调用onChange改变inOutType 状态这时候发现这句代码不生效
rules{[{ required: true, message: 请选择${inOutType 1 ? 持有人 : 负责人} }]}示例代码
TypographyForm.GroupTypographyForm.Itemlabel出库类型nameinOutTypecol{{ span: 24 }}rules{[{ required: true, message: 请选择出库类型 }]}Select placeholder出库类型 loading{inApplyLoading} onChange{onInOutTypeChange}{inApplyType inApplyType.data?.[3]?.map((item) (Select.Option value{item?.dictKey} key{item?.dictKey}{item?.dictValue}/Select.Option))}/Select
/TypographyForm.ItemTypographyForm.Itemlabel{inOutType 1 ? 持有人 : 负责人}nameholderEmployeeCodecol{{ span: 24 }}rules{[{ required: true, message: 请选择${inOutType 1 ? 持有人 : 负责人} }]}ContactsInput config{{ key: holderEmployeeCode }} /
/TypographyForm.Item原因
antd官方为了尽量少造成多余的渲染把这个主动权交由开发者自己来实现适配更多场景得到相对优秀的渲染性能
解决代码
const onInOutTypeChange (val) {setInOutType(val);// 清除指定字段的规则form.setFieldsValue({ holderEmployeeCode: });handleValidateFields();};const handleValidateFields () {form.validateFields([holderEmployeeCode]).then((values) {// 校验成功后的操作console.log(校验通过, values);}).catch((errorInfo) {// 校验失败后的操作console.log(校验失败, errorInfo);});};