1. 参数传递方式问题
- 问题:直接在 request 方法中使用依赖值(如 attendance_org_id)时,React 的闭包特性可能导致值未更新。
解决方案:通过 params 属性显式传递依赖值,确保每次依赖变化时触发请求。
|
<ProFormDependency name={['attendance_org_id']}> |
|
{({ attendance_org_id }) => ( |
|
<ProFormSelect |
|
name="dayoff_id" |
|
showSearch |
|
label="标题" |
|
params={{ attendance_org_id }} // 显式传递依赖值 配置后可以触发请求 |
|
request={async ({ attendance_org_id }) => { |
|
if (attendance_org_id) { |
|
const res = await queryByOrgId({ org_id: attendance_org_id }); |
|
return res.data.map((v) => ({ label: v.name, value: v.id })); |
|
} |
|
return []; |
|
}} |
|
/> |
|
)} |
|
</ProFormDependency> |

被折叠的 条评论
为什么被折叠?



