<Form.Item key = 'pSelect' name = 'pSelect' label="ZKSelect">
<Select >
<Option value="">请选择</Option>
<Option value="c1">c1</Option>
<Option value="c2">c2</Option>
</Select>
</Form.Item>
<Form.Item key = 'linkSelect-2-noStyle' noStyle
shouldUpdate={ (prevValues, curValues) => {
return false;
// return prevValues[`pSelect`] != curValues[`pSelect`]
}}
>
{({ getFieldValue, setFieldsValue, isFieldTouched })=>{
// 组件内容更新代码片段
let svParent = getFieldValue('pSelect');
let isOptParent = isFieldTouched('pSelect');
// console.log("[^_^:20220427-1615-002]", isOptParent, pSelectValue);
if(isOptParent){
// 操作过上级节点
let v = {'linkSelect-2':''};
// form.setFieldsValue(v);
form.resetFields(['linkSelect-2']);
}
return (
<Form.Item key = {'linkSelect-2'} name = 'linkSelect-2' label="联动 linkSelect-2" >
<Select>
<Option value="">请选择</Option>
</Select>
</Form.Item>
);
}}
</Form.Item>
shouldUpdate 返回 false 时不更新组件;即不执行 组件内容更新代码片段
shouldUpdate 返回 false 时;执行了 组件内容更新代码片段
Environment | Info |
---|---|
antd | 4.20.1 |
React | 16.14.0 |
System | macOS Monterey 12.2 |
Browser | Chrome |
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too