forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeForm.vue
More file actions
57 lines (51 loc) · 1.29 KB
/
NativeForm.vue
File metadata and controls
57 lines (51 loc) · 1.29 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
<template>
<div class="q-pa-md">
<q-form @submit="onSubmit" class="q-gutter-md">
<q-input
name="name"
v-model="name"
color="primary"
label="Full name"
filled
clearable
/>
<div>
<q-btn label="Submit" type="submit" color="primary"/>
</div>
</q-form>
<q-card v-if="submitResult.length > 0" flat bordered class="q-mt-md bg-grey-2">
<q-card-section>Submitted form contains the following formData (key = value):</q-card-section>
<q-separator />
<q-card-section class="row q-gutter-sm items-center">
<div
v-for="(item, index) in submitResult"
:key="index"
class="q-px-sm q-py-xs bg-grey-8 text-white rounded-borders text-center text-no-wrap"
>{{ item.name }} = {{ item.value }}</div>
</q-card-section>
</q-card>
</div>
</template>
<script>
export default {
data () {
return {
name: 'Jane Doe',
submitResult: []
}
},
methods: {
onSubmit (evt) {
const formData = new FormData(evt.target)
const submitResult = []
for (const [ name, value ] of formData.entries()) {
submitResult.push({
name,
value
})
}
this.submitResult = submitResult
}
}
}
</script>