vue3+recaptcha2谷歌人机验证组件

1.安装插件

npm install vue3-recaptcha2

2.

<vue-recaptcha
            :sitekey="siteKey"
            size="normal"
            theme="light"
            @verify="onVerify"
            @expire="recaptchaExpired"
            @fail="recaptchaFailed"
            v-if="isRecaptcha"
        />


<script lang="ts" setup>
// reCAPTCHA 组件
import VueRecaptcha from 'vue3-recaptcha2'

//拿到网站密钥
const siteKey = '6LflA-MqAAAAAChtyQ0Xsn337ycrybSGkHMEbPmw'

//获取token发送到后端验证
const onVerify = (token: string) => {
  console.log('Token:', token) // 发送到后端验证
}

//过期后执行动作
const recaptchaExpired = () => {
      
}
 
//失败执行动作
const recaptchaFailed = () => {
     
}

<script>

3.

使用前需注意: 
1.reCaptcha官网网站为:https://developers.google.com/recaptcha/(需要翻墙)
2.在国内使用的话,需要将demo中所有的www.google.com替换成www.recaptcha.net不然无法使用reCAPTCHA

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值