Skip to content

滑动验证 xSlideVerify


在线预览
在线模拟尺寸:

介绍

可以防止机器人刷新页面,防止恶意注册,防止恶意评论等

平台兼容

H5andriodIOS小程序UTSUNIAPP-X SDKversion
☑️☑️☑️☑️4.44+1.1.9

文件路径

ts

@/uni_modules/tmx-ui/components/x-slide-verify/x-slide-verify.uvue

使用

ts

<x-slide-verify></x-slide-verify>

Props 属性

名称说明类型默认值
width宽,允许使用auto,百分比,数字,带单位的字符串string'auto'
height高不允许使用autostring'50'
color未激活背景色string'#e9ecf0'
activeColor激活时的状态背景色,空取全局string''
darkColor暗黑时的未激活背景色string'#21232c'
successColor验证通过时的背景色string'success'
failColor验证失败时的背景色string'error'
btnColor按钮背景string'white'
btnDarkColor暗黑按钮背景,如果为空取sheetDarkColorstring'#3b3e4d'
btnFontColor空取全局主题色string""
btnFontSize按钮上的图标大小string"20"
verifyPos验证正确的位置<br>0-100是百分比,让用户滑动到哪个位置触发验证正确。number100
showVerifyBox是否显示目标指示框booleanfalse
tipsText默认的提示验证文本,请拖动到指定位置string""
tipsTextSuccess失败时的文本,验证成功string""
tipsTextFail成功时的文本,验证失败string""
tipsTextColor底部提示文本颜色string"#b8b8b8"
round圆角string"25"
resetAuto验证失败时,是否自动重置booleantrue

Events 事件

名称参数说明
start-开始拖动验证时触发
success-验证成功时触发
fail-验证失败时触发
completed-用户拖放结束时触发
reset-重置时触发

Slots 插槽

名称说明数据
activeLabel激活时的标签插槽-
btn拖动时的按钮插槽-
target目标虚拟框位置的插槽-
label未激活时的标签插槽-

Ref 方法

名称参数返回值说明
reset---

示例文件路径

json

/pages/qita/slide-verify

示例源码

uvue
vue
<template>
	<!-- #ifdef APP -->
	<scroll-view style="flex:1">
	<!-- #endif -->
	<!-- #ifdef MP-WEIXIN -->
	<page-meta :page-style="`background-color:${xThemeConfigBgColor}`">
		<navigation-bar :background-color="xThemeConfigNavBgColor" :front-color="xThemeConfigNavFontColor"></navigation-bar>
	</page-meta>
	<!-- #endif -->
		<x-sheet>
			<x-text font-size="18" class=" text-weight-b mb-8">滑动验证 xSlideVerify</x-text>
			<x-text color="#999999">
				可以防止机器人刷新页面,防止恶意注册,防止恶意评论等
			</x-text>
		</x-sheet>
		<x-sheet>
			<x-slide-verify></x-slide-verify>
		</x-sheet>
		<x-sheet>
			<x-text font-size="18" class=" text-weight-b mb-8">显示指示框并设定目标值</x-text>
			<x-slide-verify ref='verify' :verifyPos="50" :showVerifyBox="true"></x-slide-verify>
			<x-button @click="reset" class="mt-20" :block="true">重置</x-button>
		</x-sheet>
		
		<x-sheet color="primary">
			<x-text color="white" font-size="18" class=" text-weight-b mb-8">改变样式</x-text>
			<x-slide-verify activeColor="warn" :verifyPos="80" :showVerifyBox="true" round="0"></x-slide-verify>
		</x-sheet>
	<!-- #ifdef APP -->
	</scroll-view>
	<!-- #endif -->
</template>

<script setup lang="uts">
	
	const verify = ref<XSlideVerifyComponentPublicInstance|null>(null)
const reset = () => {
	if(verify.value==null) return;
	verify.value?.reset?.()
}
</script>

<style>

</style>
最近更新