【问题标题】:How to enable enter button in react-google-recaptcha after captcha verfication?验证码验证后如何在 react-google-recaptcha 中启用输入按钮?
【发布时间】:2020-04-03 16:10:26
【问题描述】:

验证码后我需要激活输入按钮,但目前它不起作用。它显示anchor:1 Uncaught (in promise) null 下面是我的整个代码。我正在使用https://www.npmjs.com/package/react-google-recaptcha

  enterkey = event => {
    console.log(event)
    if (event.key === "Enter") {
      this.submitHandler(event);
    }
  };

 captchaValidate = (value) => {
    this.enterkey();
    console.log(value)
    if (value) {
      this.setState({ disabled: false })
    } else {
      this.setState({ disabled: true })
    }
  }


<ReCAPTCHA
   sitekey={captcha_key}
   onChange={this.captchaValidate}
   className="g_capctha"
/>

我认为问题在于event,因为在调用captchaValidate 时事件变得未定义。我怎样才能在这个captchaValidate 中获取事件,因为将值更改为事件它只会给出一些类似于任何标记的文本。请帮忙。

【问题讨论】:

    标签: javascript reactjs recaptcha react-google-recaptcha


    【解决方案1】:

    您可以通过基于承诺的async 获取值来使其工作。

     captchaValidate = async (value) => {
        this.enterkey();
        console.log(value)
        if (value) {
          this.setState({ disabled: false })
        } else {
          this.setState({ disabled: true })
        }
      }
    

    【讨论】:

      猜你喜欢
      • 2015-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-15
      • 2017-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多