Skip to content

SlideVerify

A slide verification component for human-machine verification scenarios.

Basic Usage

html
<wd-slide-verify @success="handleSuccess" @fail="handleFail" />
typescript
function handleSuccess() {
  console.log('Verification successful')
}

function handleFail() {
  console.log('Verification failed')
}

Custom Text

Customize prompt text through text and success-text properties.

html
<wd-slide-verify text="Please drag the slider" success-text="Verification successful" />

Custom Size

Customize the width and height of the slide bar through width and height properties. Set the corresponding icon sizes through icon-size and success-icon-size properties.

html
<wd-slide-verify :width="250" :height="50" icon-size="60rpx" success-icon-size="30rpx" />

Custom Color

Customize colors through background-color and active-background-color properties.

html
<wd-slide-verify background-color="#E8F4FF" active-background-color="#4D94FF" />

Custom Icon

Customize icons through icon and success-icon properties, and set icon size with icon-size property.

html
<wd-slide-verify icon="arrow-right" success-icon="success" :icon-size="24" />

Custom Tolerance

Set the tolerance range (in pixels) through tolerance property, defaults to 10px.

html
<wd-slide-verify :tolerance="20" />

Disabled State

Set the disabled property to disable slide verification.

html
<wd-slide-verify disabled />

Reset Method

Get the component instance through ref and call the reset method to reset the verification state.

html
<wd-slide-verify ref="slideVerifyRef" />
<wd-button @click="handleReset">Reset</wd-button>
typescript
import { ref } from 'vue'
import type { SlideVerifyInstance } from '@/uni_modules/wot-design-uni/components/wd-slide-verify/type'

const slideVerifyRef = ref<SlideVerifyInstance>()

function handleReset() {
  slideVerifyRef.value?.reset()
}

Slots

Supports customizing content through slots.

html
<wd-slide-verify>
  <template #text>
    <text>Slide right to complete verification</text>
  </template>
  <template #success-text>
    <text>Verification passed</text>
  </template>
  <template #icon>
    <view>ICON</view>
  </template>
  <template #success-icon>
    <view style="color: red">OK</view>
  </template>
</wd-slide-verify>

Attributes

ParameterDescriptionTypeOptionsDefaultVersion
widthWidth of slide bar (unit: px)number / string-3001.14.0
heightHeight of slider (unit: px)number / string-401.14.0
toleranceTolerance range (unit: px), distance from endpoint within which verification is considered successfulnumber / string-101.14.0
textPrompt textstring-Slide right to complete verification1.14.0
success-textSuccess prompt textstring-Verification passed1.14.0
disabledWhether to disableboolean-false1.14.0
background-colorBackground colorstring-#F5F7FA1.14.0
active-background-colorActive background colorstring-#49C75F1.14.0
iconSlider icon namestring-a-chevron-rightdouble1.14.0
success-iconSuccess icon namestring-check1.14.0
icon-sizeIcon size (unit: px)number / string-201.14.0
success-icon-sizeSuccess icon size (unit: px)number / string-121.14.0

Events

Event NameDescriptionParametersVersion
successTriggered when verification succeeds-1.14.0
failTriggered when verification fails-1.14.0

Methods

You can get the component instance through ref and call the methods provided by the component:

MethodDescriptionParametersVersion
resetReset the verification component to its initial state-1.14.0

Slots API

Slot NameDescriptionVersion
textCustom prompt text content1.14.0
success-textCustom success prompt text content1.14.0
iconCustom slider icon1.14.0
success-iconCustom success icon1.14.0

External Style Classes

Class NameDescriptionVersion
custom-classRoot node style1.14.0
custom-styleRoot node style1.14.0

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.