reactjs - React antd 表单禁用提交按钮
问题描述
如何使用 antd 禁用表单提交按钮
表单验证有效,但是当验证失败时我需要在视觉上禁用表单提交按钮
这是一个 stackblitz 网址 https://stackblitz.com/edit/react-ts-z5d6tr?file=Hello.tsx
解决方案
我找到了一些优雅的方式来执行这个
<Form.Item shouldUpdate className="submit">
{() => (
<Button
type="primary"
htmlType="submit"
disabled={
!form.isFieldsTouched(true) ||
form.getFieldsError().filter(({ errors }) => errors.length)
.length > 0
}
>
Log in
</Button>
)}
</Form.Item>
推荐阅读
- python - 使用“is”标识而不是“==”相等来检查对象是否在可迭代中
- python - Python Graphene 处理多对多关系
- angular - 如何处理仅在验证成功时才应返回 Observable 的函数?
- java - TabLayout 上的标签标题未显示
- sql - 如何使用 ifelse 在 AWS QuickSight 中编写计算字段公式
- android - 使用 InputMethodManager.showSoftKeyboard() 时如何禁用自动完成/建议
- java - 如何从arrayList中获取对象的属性
- typescript - 使用 angularfirestore 获取字符串值以外的记录
- php - 输出缓冲不起作用或没有任何意义
- angular - Angular HTTP 调用似乎不起作用。我怎样才能挑出这个问题?