mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-21 07:21:46 +01:00
chore: up
This commit is contained in:
36
playground/compodium/examples/UFormExample.vue
Normal file
36
playground/compodium/examples/UFormExample.vue
Normal file
@@ -0,0 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive } from 'vue'
|
||||
|
||||
const state = reactive({ email: undefined, password: undefined })
|
||||
|
||||
function validate(data: Partial<typeof state>) {
|
||||
const errors: Array<{ name: string, message: string }> = []
|
||||
if (!data.email) errors.push({ name: 'email', message: 'Required' })
|
||||
if (!data.password) errors.push({ name: 'password', message: 'Required' })
|
||||
return errors
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UForm
|
||||
:validate="validate"
|
||||
:state="state"
|
||||
class="space-y-4"
|
||||
>
|
||||
<UFormField
|
||||
name="email"
|
||||
label="Email"
|
||||
>
|
||||
<UInput v-model="state.email" />
|
||||
</UFormField>
|
||||
<UFormField
|
||||
name="password"
|
||||
label="Password"
|
||||
>
|
||||
<UInput v-model="state.password" />
|
||||
</UFormField>
|
||||
<UButton type="submit">
|
||||
Submit
|
||||
</UButton>
|
||||
</UForm>
|
||||
</template>
|
||||
Reference in New Issue
Block a user