-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathVantValidate.vue
44 lines (40 loc) · 1015 Bytes
/
VantValidate.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script setup>
import { ref, reactive } from 'vue';
const loginForm = reactive({
username: '',
password: '',
});
const msg = ref('empty')
const submitLogin = async () => {
msg.value = 'validation passed';
}
</script>
<template>
<div>
<van-form data-testid="form" @submit="submitLogin">
<van-cell-group inset>
<van-field
v-model="loginForm.username"
label="username"
placeholder="username"
:rules="[{ required: true, message: 'please input username' }]"
/>
<van-field
v-model="loginForm.password"
type="password"
label="password"
placeholder="password"
:rules="[{ required: true, message: 'please input password' }]"
/>
</van-cell-group>
<div>
<van-button
native-type="submit"
>
login
</van-button>
</div>
</van-form>
</div>
<span>{{ msg }}</span>
</template>