OTP Input
Vue 已实现 · 还原验收 0/1 · 上游演示 · 固定版本源码
预览
Enter 123456 to verify.
用法
vue
<script setup lang="ts">
import { ref } from 'vue'
import { OTPInput } from 'beui-vue'
const code = '123456'
const value = ref('')
const status = ref<'idle' | 'success' | 'error'>('idle')
</script>
<template>
<div class="verification">
<OTPInput v-model="value" label="Verification code" :hint="`Enter ${code} to verify.`" :status="status"
success-message="Verified." error-message="Wrong code, try again." @change="status = 'idle'"
@complete="status = $event === code ? 'success' : 'error'" />
</div>
</template>
<style scoped>.verification { display: grid; justify-items: center; }</style>API
v-model 同步数字验证码,length 指定长度,mask 隐藏数字。@complete 在输入完毕时触发,status 显示校验结果。