标签:功能 time ack instant lin bad man bsp trie
①uncontrolComponent & controlComponent
If your form is incredibly simple in terms of UI feedback, uncontrolled with refs is entirely fine. You don’t have to listen to what the various articles are saying is “bad.”
feature | uncontrolled | controlled |
---|---|---|
one-time value retrieval (e.g. on submit) | ? | ? |
validating on submit | ? | ? |
instant field validation | ? | ? |
conditionally disabling submit button | ? | ? |
enforcing input format | ? | ? |
several inputs for one piece of data | ? | ? |
dynamic inputs | ? | ? |
uncontrolComponent
当不需要验证,或者提交的时候再验证等简单的功能的时候,input应该使用更为简单的 uncontrolComponent 用法的关键点为: ref获取该DOM的值
<input ref=(ref)=>{this.input = ref} />
//然后在需用用值的地通过this.input.value获取该值即可
controlComponent
需要立即验证,更改输入格式等则使用 controlComponent
标签:功能 time ack instant lin bad man bsp trie
原文地址:http://www.cnblogs.com/zhilingege/p/7856224.html