1、 基本滑块验证组件
// 安装
npm i vue-drag-verify2 -S
// 引用: main.js 中引用
import Vue from 'vue'
import dragVerify from 'vue-drag-verify2'
Vue.use(dragVerify)
<template>
<div>
<h3>模块验证:</h3>
<div class="verifyBox">
<el-row style="margin-top:10px;">
<drag-verify ref="dragVerify" :width="300" :isPassing.sync="isPassing" text="请按住滑块拖动" successtext="验证通过"
handlerIcon="el-icon-d-arrow-right" successIcon="el-icon-circle-check" @passcallback="passcallback">
<i v-show="!isPassing" slot="textBefore" class="el-icon-lock"></i>
</drag-verify>
</el-row>
<el-button style="margin-top:5px;margin-left:10px;" size="small" @click="reset">还原</el-button>
</div>
</div>
</template>
<script>
export default {
data() {
return {
isPassing: false
}
},
methods: {
passcallback() {
this.$message({
message: "验证通过",
type: "success"
});
},
reset() {
this.isPassing = false;
this.$refs.dragVerify.reset()
},
},
}
</script>
<style>
.verifyBox {
display: flex;
}
</style>
2、图片滑块组件
// 安装
npm i vue-drag-verify-img -S
<template>
<div>
<h3>图片滑块:</h3>
<dragVerifyImg ref="dragVerify" :imgsrc=" imgsrc" :isPassing.sync="isPassing" :showRefresh="true" text="请按住滑块拖动"
successtext="验证通过" handlerIcon="el-icon-d-arrow-right" successIcon="el-icon-circle-check"
@passcallback="passcallback">
</dragVerifyImg>
<el-button type="primary" @click="reset">还原</el-button>
</div>
</template>
<script>
import dragVerifyImg from 'vue-drag-verify-img'
export default {
data() {
return {
isPassing: false,
value: "",
imgsrc: "http://celiang.oss-cn-hangzhou.aliyuncs.com/measurement/2022-04/26/y3zT5PHPCPlkxi1650939813220426.jpg"
}
},
components: {
dragVerifyImg
},
methods: {
passcallback() {
this.$message({
message: "验证通过",
type: "success"
});
},
reset() {
this.isPassing = false;
this.$refs.dragVerify.reset()
},
},
}
</script>
<style>
.verifyBox {
display: flex;
}
</style>
以上就是 短视频直播源码,拖动滑块实现图片验证效果,更多内容欢迎关注之后的文章