1.0.0 • Published 1 year ago

slide-verify-code v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

vue3-puzzle-vcode npm npm downloads

img

安装

  npm install slide-verify-code --save

最简单例子

<template>
  <Vcode :show="isShow" @success="onSuccess" @close="onClose"/>
  <button @click="onShow">开始验证</button>
</template>

<script setup>
import {ref} from "vue";
import Vcode from "slide-verify-code";

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用户点击遮罩层的回调
1.0.0

1 year ago

1.0.8

1 year ago