vue3 拖拽验证

https://github.com/MrXujiang/vue-slider-vertify


https://github.com/MrXujiang/h5-Dooring



https://github.com/xingyuv/captcha-plus



这个也不错

https://github.com/lirongtong/miitvip-captcha



下面这个好使

https://github.com/javaLuo/vue-puzzle-vcode/blob/master/README3.md

vue3-puzzle-vcode

vue-puzzle-vcode-vue3.zip

安装 vue3-puzzle-vcode

  npm install vue3-puzzle-vcode --save

最简单例子

<template>
    <button @click="onShow">开始验证</button>
    <Vcode :show="isShow" @success="onSuccess" @close="onClose" />
</template>
<script setup>  
import { ref } from "vue";  
import Vcode from "vue3-puzzle-vcode";  
const isShow = ref(false);  
const onShow = () => {    
isShow.value = true;  
};  
const onClose = () => {    
isShow.value = false;  
};  
const onSuccess = () => {    
onClose(); // 验证成功,需要手动关闭模态框  
};
</script>

参数

字段类型默认值说明
showBooleanfalse是否显示验证码弹框
canvasWidthNumber310主图区域的宽度,单位 px
canvasHeightNumber160主图区域的高度,单位 px
puzzleScaleNumber1拼图块(小的拼图)的大小比例,0.2 ~ 2 ,数字越大,拼图越大
sliderSizeNumber50左下角用户拖动的那个滑块的尺寸,单位 px
rangeNumber10判断成功的误差范围,单位 px, 滑动的距离和拼图的距离小于等于此值时,会判定重合
imgsArraynull自定义图片,见下方例子
successTextString"验证通过!"验证成功时的提示文字
failTextString"验证失败,请重试"验证失败时的提示文字
sliderTextString"拖动滑块完成拼图"下方滑动条里的文字

事件

事件名返回值说明
success偏差值验证通过时会触发,返回值是用户移动的距离跟目标距离的偏差值 px
fail偏差值验证失败时会触发,返回值同上
closenull用户点击遮罩层的回调

自定义图片

<template>
  <Vcode :imgs="imgs" />
</template>
<script>
import Vcode from "vue3-puzzle-vcode";
import Img1 from "~/assets/img1.png";
import Img2 from "~/assets/img2.png";
const imgs = [Img1, Img2];
</script>

说明

  • 当不传递 imgs 字段或图片加载出错时,会自动生成随机图片

  • 模态框的显示和隐藏完全由父级控制,所以用户通过验证后,需要手动隐藏模态框


打赏

看恩吧
网站不承担任何有关评论的责任
  • 最新评论
  • 总共条评论
取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦