Skip to content

滑动验证 xSlideVerify ​


预览

介绍 ​

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

平台兼容 ​

HarmonyH5andriodIOS小程序UTSUNIAPP-X SDKversion
☑☑☑️☑️☑️☑️4.76+1.1.18

文件路径 ​

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高不允许使用auto
string'50'
color未激活背景色
string'#e9ecf0'
activeColor激活时的状态背景色,空取全局
string''
darkColor暗黑时的未激活背景色
string'#21232c'
successColor验证通过时的背景色
string'success'
failColor验证失败时的背景色
string'error'
btnColor按钮背景
string'white'
btnDarkColor暗黑按钮背景,如果为空取sheetDarkColor
string'#3b3e4d'
btnFontColor空取全局主题色
string""
btnFontSize按钮上的图标大小
string"20"
verifyPos验证正确的位置
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 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>
</template>

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

<style>

</style>
最近更新