更新时间:2020-09-18 01:15:10
更新说明:新增passfail回调,可在验证失败时重置滑块位置
更新时间:2020-07-05 23:41:19
更新说明:更新文档,优化示例中刷新图片的逻辑。
更新时间:2020-05-14 21:23:31
更新说明:新增图片拼图验证功能
需对父元素或html设置user-select: none
按需引入对应组件
// 基本滑块验证组件 import dragVerify from "@/components/core/dragVerify"; // 图片滑块组件 import dragVerifyImg from "@/components/core/dragVerifyImg"; // 旋转图片滑块组件 import dragVerifyImgRotate from "@/components/core/dragVerifyImgRotate"; components{ dragVerify, dragVerifyImg, dragVerifyImgRotate }
引入以下代码
<drag-verify ref="dragVerify" :isPassing.sync="isPassing2" text="请按住滑块拖动" successText="验证通过" handlerIcon="el-icon-d-arrow-right" successIcon="el-icon-circle-check" > </drag-verify>
<drag-verify-img ref="sss" :imgsrc="t3" :isPassing.sync="isPassing" :showRefresh="true" text="请按住滑块拖动" successText="验证通过" handlerIcon="el-icon-d-arrow-right" successIcon="el-icon-circle-check" @refresh="reimg" @passcallback="pass" > </drag-verify-img>
<drag-verify-img-rotate ref="sss" :imgsrc="logo" :isPassing.sync="isPassing" :showTips="true" text="请按住滑块拖动" successText="验证通过" handlerIcon="el-icon-d-arrow-right" successIcon="el-icon-circle-check" @refresh="reimg" > </drag-verify-img-rotate>
有需求可以在评论里提出来
亲测可用:
npm i vue-drag-verify2 -S https://www.jq22.com/jquery-info23002 import dragVerify from 'vue-drag-verify2' components: { JcRange }, <drag-verify ref="dragVerify" :isPassing.sync="isPassing2" text="请按住滑块拖动" successText="验证通过" handlerIcon="el-icon-d-arrow-right" successIcon="el-icon-circle-check"> </drag-verify>回复
<template> <div> <drag-verify ref="dragVerify7" :width="300" :isPassing.sync="isPassing7" text="请按住滑块拖动" successText="验证通过" handlerIcon="el-icon-d-arrow-right" successIcon="el-icon-circle-check" @passcallback="passcallback3" > </drag-verify> <el-button style="margin-top:5px;" size="small" @click="reset">还原</el-button> </div> </template> <script> import dragVerify from 'vue-drag-verify' export default { data() { return { isPassing7: false } }, components: { dragVerify }, methods: { passcallback3() { this.$message({ message: "验证通过", type: "success" }); }, reset() { this.isPassing7 = false; this.$refs.dragVerify7.reset() }, }, } </script>