在reactjs中提交后,如何禁用ANTD表格提交按钮?
我有这样的ANTD表格: -
<Form {...layout} form={form} name={formTitle(window.location.pathname)} onFinish={submitForm}>
<Form.Item name="name" label="Name" rules={NAME_VALIDATION}>
<Input value={name} onChange={({ target: { value, } }) => setName(value)}/>
</Form.Item>
<Form.Item {...tailLayout}>
<Button type="primary" htmlType="submit">{formCardTitle(window.location.pathname)}</Button>
<Button htmlType="button" onClick={onReset}>
Reset
</Button>
</Form.Item>
</Form>
我想禁用表单上的提交按钮。类似的内容: -
const submitForm = async () => {
.................
.................
// disable submit button
}
我知道如何在表单中禁用按钮,类似的内容: -
<Button type="primary" htmlType="submit" disabled={!(name)}>
{formCardTitle(window.location.pathname)}
</Button>
但是我只想在表单提交后仅在submitform()函数内禁用按钮。 我该怎么做?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里一个示例
Here is the actual implementation in codesandbox
Here the one Example