首页 > 其他 > 详细

react知识点汇总

时间:2017-11-18 12:31:54      阅读:234      评论:0      收藏:0      [点我收藏+]

①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.”

featureuncontrolledcontrolled
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 

 

react知识点汇总

原文:http://www.cnblogs.com/zhilingege/p/7856224.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!