55 lines
1.3 KiB
Vue
55 lines
1.3 KiB
Vue
<script setup lang="ts">
|
||
import { ref } from "vue";
|
||
import {
|
||
Description,
|
||
InputOTP,
|
||
InputOTPGroup,
|
||
InputOTPSeparator,
|
||
InputOTPSlot,
|
||
Label,
|
||
} from "@heroui-vue/components";
|
||
|
||
const value = ref("");
|
||
|
||
import { useId } from "vue";
|
||
const otpDescriptionId = useId();
|
||
const otpLabelId = useId();
|
||
</script>
|
||
|
||
<template>
|
||
<div class="flex w-[280px] flex-col gap-2">
|
||
<Label :id="otpLabelId">验证账户</Label>
|
||
<InputOTP
|
||
:aria-describedby="otpDescriptionId"
|
||
:aria-labelledby="otpLabelId"
|
||
v-model="value"
|
||
:max-length="6"
|
||
>
|
||
<InputOTPGroup>
|
||
<InputOTPSlot :index="0" />
|
||
<InputOTPSlot :index="1" />
|
||
<InputOTPSlot :index="2" />
|
||
</InputOTPGroup>
|
||
<InputOTPSeparator />
|
||
<InputOTPGroup>
|
||
<InputOTPSlot :index="3" />
|
||
<InputOTPSlot :index="4" />
|
||
<InputOTPSlot :index="5" />
|
||
</InputOTPGroup>
|
||
</InputOTP>
|
||
<Description :id="otpDescriptionId">
|
||
<template v-if="value.length > 0">
|
||
值:{{ value }} ({{ value.length }}/6) •
|
||
<button
|
||
class="font-medium text-foreground underline"
|
||
type="button"
|
||
@click="value = ''"
|
||
>
|
||
清空
|
||
</button>
|
||
</template>
|
||
<template v-else>请输入 6 位验证码</template>
|
||
</Description>
|
||
</div>
|
||
</template>
|