This repository has been archived by the owner on Jun 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
CompositionHome.vue
125 lines (120 loc) · 3.18 KB
/
CompositionHome.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<template>
<div class="home">
<br>
Write anything here and watch the addressbar. Later <a href="/">reload the application</a>
to see that the default value in the first field was taken from the local storage.<br><br>
<table>
<tr>
<td>
Field stored to the local storage:
</td>
<td>
<input v-model="query.search"><br><br>
</td>
</tr>
<tr>
<td>
Simple text field
</td>
<td>
<input v-model="query.search2"><br><br>
</td>
</tr>
<tr>
<td>
Number field with the default value of 10:
</td>
<td>
<input type="number" v-model="query.num"><br><br>
</td>
</tr>
<tr>
<td>
Checkbox:
</td>
<td>
<input type="checkbox" v-model="query.check"><br><br>
</td>
</tr>
<tr>
<td>
Array (multiple selection, control-click for selecting both values):
</td>
<td>
<select multiple v-model="query.option">
<option value="first">First choice</option>
<option value="second">Second choice</option>
</select><br><br>
</td>
</tr>
<tr>
<td>
Comma-separated array (multiple selection, control-click for selecting both values):
</td>
<td>
<select multiple v-model="query.option2">
<option value="first">First choice</option>
<option value="second">Second choice</option>
</select><br><br>
</td>
</tr>
<tr>
<td>
Space-separated array (multiple selection, control-click for selecting both values):
</td>
<td>
<select multiple v-model="query.option3">
<option value="first">First choice</option>
<option value="second">Second choice</option>
</select><br><br>
</td>
</tr>
<tr>
<td>
Add and remove (the query param is called dynarr):
</td>
<td>
<input v-model="tmp" placeholder="Enter value"><br><br>
<button @click="query.addValue('dynarr', tmp)">Add</button>
<button @click="query.removeValue('dynarr', tmp)">Remove</button>
<br>
</td>
</tr>
</table>
<br><br>
<button @click="convert">Convert simple text field to numeric model (can be used to, for example, define
datatype later)
</button>
<br><br>
query equals:
<pre>{{ query }}</pre>
stringified query:
<pre>{{ JSON.stringify(query, null, 4) }}</pre>
definition (not reactive):
<pre>{{ query.__definition }}</pre>
</div>
</template>
<script>
import { IntDatatype, CommaArrayDatatype, useQuery } from '@oarepo/vue-query-synchronizer'
import { ref } from 'vue'
export default {
name: 'home',
components: {},
props: {
another: String
},
setup () {
const query = useQuery()
query.define('dynarr', CommaArrayDatatype, [])
const tmp = ref('')
function convert () {
this.query.define('search2', IntDatatype)
}
return {
query,
tmp,
convert
}
}
}
</script>