【问题标题】:React, getting an error when a function is passed to the required attributeReact,将函数传递给所需属性时出错
【发布时间】:2017-05-26 11:48:36
【问题描述】:

我正在尝试验证字段必填字段,并且我正在将一个函数传递给必填字段。但是该函数似乎没有被调用,现在我也收到一个错误(“加载资源失败:服务器响应状态为 403”)。有什么办法解决这个问题吗?

【问题讨论】:

    标签: validation reactjs input required


    【解决方案1】:
    this.isReq.bind(this)
    

    好像你的电话超出范围试试这个。

    【讨论】:

    • 只需拨打this.isReq()
    【解决方案2】:

    你可以像这样使用 :: 绑定操作符

    ...
     <input 
      type='text'
      required={ ::this.isReq }
      requiredMessage="Enter the Validity End Period."
    />
    ... 
    

    【讨论】:

      猜你喜欢
      • 2019-06-27
      • 2015-08-26
      • 2018-05-07
      • 1970-01-01
      • 1970-01-01
      • 2019-06-02
      • 1970-01-01
      • 2020-06-26
      • 1970-01-01
      相关资源
      最近更新 更多