在Material-ui中,何时使用输入与文本字段来构建表单? [英] In Material-ui when do we use Input vs. Textfield for building a form?

查看:305
本文介绍了在Material-ui中,何时使用输入与文本字段来构建表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这只是一个基本问题,但是到目前为止还没有找到任何合理的解释.我是最近开始使用React并使用material-ui的初学者.我不清楚何时使用Input vs. Textfield构建表单?

Maybe this is just a basic question, but so far have not found any reasonable explanation. I am a beginner in react and using material-ui very recently. I am not very clear on when to use an Input vs. Textfield for building a form?

看看文档,感觉TextField是Input可以做的事情的超集,但不确定. Material-ui站点在文本字段和输入示例中都使用了示例,而没有说明一个相对于另一个以及任何用例的好处.

Looking at documentation, it feels like TextField is a superset of what Input can do, but not sure. Material-ui site uses examples for text field and input both, without stating benefits of one over the other and any use cases.

请提出建议.

推荐答案

在大多数情况下,应该使用TextField而不是它委派给的下级组件(例如Input).

For most use cases, you should use TextField rather than the lower-level components that it delegates to (such as Input).

文档的相关部分在这里: https://material-ui. com/demos/text-fields/#components .

The relevant part of the documentation is here: https://material-ui.com/demos/text-fields/#components.

特别是这一行:

TextField由较小的组件(FormControl,Input,FilledInput,InputLabel,OutlinedInput和FormHelperText)组成,您可以直接利用它们来显着自定义表单输入.

TextField is composed of smaller components ( FormControl, Input, FilledInput, InputLabel, OutlinedInput, and FormHelperText ) that you can leverage directly to significantly customize your form inputs.

使用这些较低级组件的主要原因是,您是否需要以某种方式自定义表单输入,而使用TextField不支持这种方式.

The main reason to use these lower-level components is if you need to customize your form input in some way that isn't supported using TextField.

这篇关于在Material-ui中,何时使用输入与文本字段来构建表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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