Files
heroui-vue/apps/docs/demos/field-error-basic.vue

18 lines
536 B
Vue

<script setup lang="ts">
import { computed, ref } from "vue";
import { FieldError, Input, Label, TextField } from "@heroui-vue/components";
const value = ref("jr");
const isInvalid = computed(
() => value.value.length > 0 && value.value.length < 3,
);
</script>
<template>
<TextField v-model="value" class="w-64" :is-invalid="isInvalid">
<Label for="username">用户名</Label>
<Input id="username" placeholder="输入用户名" />
<FieldError>用户名至少需要 3 个字符</FieldError>
</TextField>
</template>