mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-15 04:29:37 +01:00
24 lines
608 B
Vue
24 lines
608 B
Vue
<script setup lang="ts">
|
|
const state = reactive({ fullName: '' })
|
|
|
|
async function onSubmit() {
|
|
return new Promise<void>(res => setTimeout(res, 1000))
|
|
}
|
|
|
|
async function validate(data: Partial<typeof state>) {
|
|
if (!data.fullName?.length) return [{ name: 'fullName', message: 'Required' }]
|
|
return []
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<UForm :state="state" :validate="validate" @submit="onSubmit">
|
|
<UFormField name="fullName" label="Full name">
|
|
<UInput v-model="state.fullName" />
|
|
</UFormField>
|
|
<UButton type="submit" class="mt-2" loading-auto>
|
|
Submit
|
|
</UButton>
|
|
</UForm>
|
|
</template>
|