针对状态禁用整个表单元素.反应 [英] Disable entire form elements with respect to a state. React

查看:64
本文介绍了针对状态禁用整个表单元素.反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用isFetching道具禁用输入, 但这变得多余了,因为我必须将其保留在每个输入字段中. 有没有办法禁用整个表格? 就像<form>标记中的disable属性一样?

I am disabling the inputs using the isFetching prop, but this is getting reduntant as I have to keep this in every input field. Is there a way to disable the entire form? Like a disable property in <form> tag or something?

<form>
  <input type="text" disabled={this.props.isFetching} />
  <input type="text" disabled={this.props.isFetching} />
</form>

推荐答案

我认为这应该可以解决您的问题 https://stackoverflow. com/a/17186342/3298693 .

I think this should solve your problem https://stackoverflow.com/a/17186342/3298693.

您应将表单插入元素<fieldset disabled="disabled">中.这将使整个表单被禁用.

You should insert your form inside an element <fieldset disabled="disabled">. This will make the whole form disabled.

这篇关于针对状态禁用整个表单元素.反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆