Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/472.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用谷歌&x27;在Aurelia应用程序中使用s reCAPTCHA_Javascript_Recaptcha_Aurelia - Fatal编程技术网

Javascript 使用谷歌&x27;在Aurelia应用程序中使用s reCAPTCHA

Javascript 使用谷歌&x27;在Aurelia应用程序中使用s reCAPTCHA,javascript,recaptcha,aurelia,Javascript,Recaptcha,Aurelia,我一直在谷歌上搜索,但似乎找不到在Aurelia应用程序中使用的方法 如果可能的话,我想将其用作自定义元素 从'aurelia framework'导入{inject,customElement}; //可能来自url,比如https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit 从“google recaptcha”导入recaptcha; @customElement(‘验证码’) @注射(再注

我一直在谷歌上搜索,但似乎找不到在Aurelia应用程序中使用的方法

如果可能的话,我想将其用作自定义元素

从'aurelia framework'导入{inject,customElement};
//可能来自url,比如https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit
从“google recaptcha”导入recaptcha;
@customElement(‘验证码’)
@注射(再注射)
导出类验证码{
构造器(recaptcha){
this.recaptcha=recaptcha;
}
//添加代码以初始化验证码并处理回调
}

以下是如何创建显示reCAPTCHA的自定义元素:

recaptcha.js

import{inject,noView,bindable}来自“aurelia框架”;
const recaptchaCallbackName='setRecaptchaReady';
const ready=new Promise(resolve=>window[recaptchaCallbackName]=resolve);
// https://developers.google.com/recaptcha/docs/display#explicit_render
让script=document.createElement('script');
script.src=`https://www.google.com/recaptcha/api.js?onload=${recaptchaCallbackName}&render=explicit`;
script.async=true;
script.defer=true;
document.head.appendChild(脚本);
const sitekey='6LcddxgTAAAAAMmkEMa1Vrp6TNcZG8kMMkcn VCK';
@noView()
@注入(元素)
出口类Recaptcha{
@可绑定验证;
@可绑定主题='light';
构造函数(元素){
this.element=元素;
}
附({
ready.then(()=>grecaptcha.render(this.element,{
sitekey:sitekey,
主题:这个主题,
回调:这是已验证的
}));
}
}
用法:




以下是如何创建显示reCAPTCHA的自定义元素:

recaptcha.js

import{inject,noView,bindable}来自“aurelia框架”;
const recaptchaCallbackName='setRecaptchaReady';
const ready=new Promise(resolve=>window[recaptchaCallbackName]=resolve);
// https://developers.google.com/recaptcha/docs/display#explicit_render
让script=document.createElement('script');
script.src=`https://www.google.com/recaptcha/api.js?onload=${recaptchaCallbackName}&render=explicit`;
script.async=true;
script.defer=true;
document.head.appendChild(脚本);
const sitekey='6LcddxgTAAAAAMmkEMa1Vrp6TNcZG8kMMkcn VCK';
@noView()
@注入(元素)
出口类Recaptcha{
@可绑定验证;
@可绑定主题='light';
构造函数(元素){
this.element=元素;
}
附({
ready.then(()=>grecaptcha.render(this.element,{
sitekey:sitekey,
主题:这个主题,
回调:这是已验证的
}));
}
}
用法: