我根据此处的说明使用react-recaptcha-google
:https://medium.com/codeep-io/how-to-use-google-recaptcha-with-react-38a5cd535e0d
<ReCaptcha
ref={(el) => {this.captchaDemo = el;}}
size="normal"
render="explicit"
sitekey="my_key"
onloadCallback={this.onLoadRecaptcha}
verifyCallback={this.verifyCallback}
/>
verifyCallback(recaptchaToken) {
// This shows recaptchaToken
console.log(recaptchaToken, "<= your recaptcha token")
}
验证码已过期,一段时间后会提示再次验证。
提交表格时,我需要检查令牌/验证码是否仍然有效-怎么做?如何验证提交的验证码是否过期?
如何在recaptchaToken
功能之外再次获得verifyCallback
?
<button className="btn nvh-cta center-block" onClick={(e) => this.submitFeedback(e)}>SUBMIT</button>
submitFeedback(e) {
console.log(this.captchaDemo); <- there is no token present in the captcha properties
}