簡體   English   中英

驗證碼驗證后如何在 react-google-recaptcha 中啟用輸入按鈕?

[英]How to enable enter button in react-google-recaptcha after captcha verfication?

我需要在驗證碼驗證后激活輸入按鈕,但目前它不起作用。 它顯示了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中獲取事件,因為將值更改為事件只會給出一些類似於任何標記的文本。 請幫忙。

您可以通過進行基於async承諾的值獲取來使其工作。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM