recaptcha vue_适用于Vue.js的Google ReCAPTCHA组件
recaptcha vue
验证码 (vue-recaptcha)
Google ReCAPTCHA component for vue.
适用于vue的Google ReCAPTCHA组件。
安装 (Install)
NPM (NPM)
$ npm install --save vue-recaptcha
CDN (CDN)
<script src="https://unpkg.com/[email protected]/dist/vue-recaptcha.js"></script>
<!-- Minify -->
<script src="https://unpkg.com/[email protected]/dist/vue-recaptcha.min.js"></script>
用法 (Usage)
开始吧 (Get started)
Place this in head to load reCAPTCHA:
将其放在头部以加载reCAPTCHA:
<script src="https://www.google.com/recaptcha/api.js?onload=vueRecaptchaApiLoaded&render=explicit" async defer>
</script>
这里需要说明一下,在中国请用 www.recaptcha.net
替换 www.google.com
:
<script src="https://www.recaptcha.net/recaptcha/api.js?onload=vueRecaptchaApiLoaded&render=explicit" async defer>
</script>
With `onload` callback, it will notify us when the api is ready for use.
Then include vue-recaptcha
in your app.
然后在您的应用程序中包含vue-recaptcha
。
<template>
<vue-recaptcha sitekey="Your key here"></vue-recaptcha>
</template>
<script>
import VueRecaptcha from 'vue-recaptcha';
export default {
...
components: { VueRecaptcha }
};
</script>
将挑战绑定到按钮 (Bind Challenge to Button)
<template>
<vue-recaptcha sitekey="Your key here">
<button>Click me</button>
</vue-recaptcha>
</template>
<script>
import VueRecaptcha from 'vue-recaptcha';
export default {
...
components: { VueRecaptcha }
};
</script>
Notice: You could only place one element as vue-recaptcha
child.
注意:您只能放置一个元素作为vue-recaptcha
子级。
For more information, please reference to example
有关更多信息,请参考示例
API (API)
道具 (Props)
-
sitekey (required)
sitekey(必填)
ReCAPTCHA site key
ReCAPTCHA网站密钥 -
theme (optional)
主题(可选)
The color theme for reCAPTCHA
reCAPTCHA的颜色主题 -
type (optional)
类型(可选)
The type of reCAPTCHA
reCAPTCHA的类型 -
size (optional)
大小(可选)
The size of reCAPTCHA
reCAPTCHA的大小 -
tabindex (optional)
tabindex(可选)
The tabindex of reCAPTCHA
reCAPTCHA的tabindex -
badge (optional) (Invisible ReCAPTCHA only)
徽章(可选)(仅不可见的ReCAPTCHA)
Position of the reCAPTCHA badge
reCAPTCHA徽章的位置
方法 (Methods)
-
reset
重启
Reset reCAPTCHA instance
重置reCAPTCHA实例 -
execute
执行
Invoke reCAPTCHA challenge
调用reCAPTCHA挑战
大事记 (Events)
-
verify(response)
验证(响应)
Emit on reCAPTCHA verified
通过reCAPTCHA验证
response
is the successful reCAPTCHA responseresponse
是成功的reCAPTCHA响应 -
expired()
expired()
Emit on reCAPTCHA expired
reCAPTCHA上的发射已过期 -
render(id)
渲染(id)
Emit on reCAPTCHA mounted on DOM
在安装在DOM上的reCAPTCHA上发射
id
is the widget id of the componentid
是组件的小部件ID
翻译自: https://vuejsexamples.com/google-recaptcha-component-for-vue-js/
recaptcha vue
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)