|
1 | 1 | <template>
|
2 |
| - <v-data-table |
3 |
| - :headers="headers" |
4 |
| - :items="desserts" |
5 |
| - :sort-by="[{ key: 'calories', order: 'asc' }, { key: 'fat', order: 'desc' }]" |
6 |
| - multi-sort |
7 |
| - ></v-data-table> |
| 2 | + <div> |
| 3 | + <v-alert class="mb-2" density="compact" variant="outlined"> |
| 4 | + <strong>Hint:</strong> Hold <v-kbd>Alt</v-kbd> to prepend new columns to <v-code>sort-by</v-code> array |
| 5 | + </v-alert> |
| 6 | + <v-data-table |
| 7 | + :headers="headers" |
| 8 | + :items="desserts" |
| 9 | + :multi-sort="{ mode: 'append', modifier: 'alt' }" |
| 10 | + :sort-by="[{ key: 'calories', order: 'asc' }, { key: 'fat', order: 'desc' }]" |
| 11 | + ></v-data-table> |
| 12 | + </div> |
8 | 13 | </template>
|
9 | 14 |
|
10 | 15 | <script setup>
|
|
22 | 27 | { title: 'Iron (%)', key: 'iron' },
|
23 | 28 | ]
|
24 | 29 | const desserts = [
|
25 |
| - { |
26 |
| - name: 'Frozen Yogurt', |
27 |
| - calories: 200, |
28 |
| - fat: 6, |
29 |
| - carbs: 24, |
30 |
| - protein: 4, |
31 |
| - iron: 1, |
32 |
| - }, |
33 |
| - { |
34 |
| - name: 'Ice cream sandwich', |
35 |
| - calories: 200, |
36 |
| - fat: 9, |
37 |
| - carbs: 37, |
38 |
| - protein: 4.3, |
39 |
| - iron: 1, |
40 |
| - }, |
41 |
| - { |
42 |
| - name: 'Eclair', |
43 |
| - calories: 300, |
44 |
| - fat: 16, |
45 |
| - carbs: 23, |
46 |
| - protein: 6, |
47 |
| - iron: 7, |
48 |
| - }, |
49 |
| - { |
50 |
| - name: 'Cupcake', |
51 |
| - calories: 300, |
52 |
| - fat: 3.7, |
53 |
| - carbs: 67, |
54 |
| - protein: 4.3, |
55 |
| - iron: 8, |
56 |
| - }, |
57 |
| - { |
58 |
| - name: 'Gingerbread', |
59 |
| - calories: 400, |
60 |
| - fat: 16, |
61 |
| - carbs: 49, |
62 |
| - protein: 3.9, |
63 |
| - iron: 16, |
64 |
| - }, |
65 |
| - { |
66 |
| - name: 'Jelly bean', |
67 |
| - calories: 400, |
68 |
| - fat: 0, |
69 |
| - carbs: 94, |
70 |
| - protein: 0, |
71 |
| - iron: 0, |
72 |
| - }, |
73 |
| - { |
74 |
| - name: 'Lollipop', |
75 |
| - calories: 400, |
76 |
| - fat: 0.2, |
77 |
| - carbs: 98, |
78 |
| - protein: 0, |
79 |
| - iron: 2, |
80 |
| - }, |
81 |
| - { |
82 |
| - name: 'Honeycomb', |
83 |
| - calories: 400, |
84 |
| - fat: 3.2, |
85 |
| - carbs: 87, |
86 |
| - protein: 6.5, |
87 |
| - iron: 45, |
88 |
| - }, |
89 |
| - { |
90 |
| - name: 'Donut', |
91 |
| - calories: 500, |
92 |
| - fat: 25, |
93 |
| - carbs: 51, |
94 |
| - protein: 4.9, |
95 |
| - iron: 22, |
96 |
| - }, |
97 |
| - { |
98 |
| - name: 'KitKat', |
99 |
| - calories: 500, |
100 |
| - fat: 26, |
101 |
| - carbs: 65, |
102 |
| - protein: 7, |
103 |
| - iron: 6, |
104 |
| - }, |
| 30 | + { name: 'Frozen Yogurt', calories: 200, fat: 6, carbs: 24, protein: 4, iron: 1 }, |
| 31 | + { name: 'Ice cream sandwich', calories: 200, fat: 9, carbs: 37, protein: 4.3, iron: 1 }, |
| 32 | + { name: 'Eclair', calories: 300, fat: 16, carbs: 23, protein: 6, iron: 7 }, |
| 33 | + { name: 'Cupcake', calories: 300, fat: 3.7, carbs: 67, protein: 4.3, iron: 8 }, |
| 34 | + { name: 'Gingerbread', calories: 400, fat: 16, carbs: 49, protein: 3.9, iron: 16 }, |
| 35 | + { name: 'Jelly bean', calories: 400, fat: 0, carbs: 94, protein: 0, iron: 0 }, |
| 36 | + { name: 'Lollipop', calories: 400, fat: 0.2, carbs: 98, protein: 0, iron: 2 }, |
| 37 | + { name: 'Honeycomb', calories: 400, fat: 3.2, carbs: 87, protein: 6.5, iron: 45 }, |
| 38 | + { name: 'Donut', calories: 500, fat: 25, carbs: 51, protein: 4.9, iron: 22 }, |
| 39 | + { name: 'KitKat', calories: 500, fat: 26, carbs: 65, protein: 7, iron: 6 }, |
105 | 40 | ]
|
106 | 41 | </script>
|
107 | 42 |
|
|
123 | 58 | { title: 'Iron (%)', key: 'iron' },
|
124 | 59 | ],
|
125 | 60 | desserts: [
|
126 |
| - { |
127 |
| - name: 'Frozen Yogurt', |
128 |
| - calories: 200, |
129 |
| - fat: 6.0, |
130 |
| - carbs: 24, |
131 |
| - protein: 4.0, |
132 |
| - iron: 1, |
133 |
| - }, |
134 |
| - { |
135 |
| - name: 'Ice cream sandwich', |
136 |
| - calories: 200, |
137 |
| - fat: 9.0, |
138 |
| - carbs: 37, |
139 |
| - protein: 4.3, |
140 |
| - iron: 1, |
141 |
| - }, |
142 |
| - { |
143 |
| - name: 'Eclair', |
144 |
| - calories: 300, |
145 |
| - fat: 16.0, |
146 |
| - carbs: 23, |
147 |
| - protein: 6.0, |
148 |
| - iron: 7, |
149 |
| - }, |
150 |
| - { |
151 |
| - name: 'Cupcake', |
152 |
| - calories: 300, |
153 |
| - fat: 3.7, |
154 |
| - carbs: 67, |
155 |
| - protein: 4.3, |
156 |
| - iron: 8, |
157 |
| - }, |
158 |
| - { |
159 |
| - name: 'Gingerbread', |
160 |
| - calories: 400, |
161 |
| - fat: 16.0, |
162 |
| - carbs: 49, |
163 |
| - protein: 3.9, |
164 |
| - iron: 16, |
165 |
| - }, |
166 |
| - { |
167 |
| - name: 'Jelly bean', |
168 |
| - calories: 400, |
169 |
| - fat: 0.0, |
170 |
| - carbs: 94, |
171 |
| - protein: 0.0, |
172 |
| - iron: 0, |
173 |
| - }, |
174 |
| - { |
175 |
| - name: 'Lollipop', |
176 |
| - calories: 400, |
177 |
| - fat: 0.2, |
178 |
| - carbs: 98, |
179 |
| - protein: 0, |
180 |
| - iron: 2, |
181 |
| - }, |
182 |
| - { |
183 |
| - name: 'Honeycomb', |
184 |
| - calories: 400, |
185 |
| - fat: 3.2, |
186 |
| - carbs: 87, |
187 |
| - protein: 6.5, |
188 |
| - iron: 45, |
189 |
| - }, |
190 |
| - { |
191 |
| - name: 'Donut', |
192 |
| - calories: 500, |
193 |
| - fat: 25.0, |
194 |
| - carbs: 51, |
195 |
| - protein: 4.9, |
196 |
| - iron: 22, |
197 |
| - }, |
198 |
| - { |
199 |
| - name: 'KitKat', |
200 |
| - calories: 500, |
201 |
| - fat: 26.0, |
202 |
| - carbs: 65, |
203 |
| - protein: 7, |
204 |
| - iron: 6, |
205 |
| - }, |
| 61 | + { name: 'Frozen Yogurt', calories: 200, fat: 6.0, carbs: 24, protein: 4.0, iron: 1 }, |
| 62 | + { name: 'Ice cream sandwich', calories: 200, fat: 9.0, carbs: 37, protein: 4.3, iron: 1 }, |
| 63 | + { name: 'Eclair', calories: 300, fat: 16.0, carbs: 23, protein: 6.0, iron: 7 }, |
| 64 | + { name: 'Cupcake', calories: 300, fat: 3.7, carbs: 67, protein: 4.3, iron: 8 }, |
| 65 | + { name: 'Gingerbread', calories: 400, fat: 16.0, carbs: 49, protein: 3.9, iron: 16 }, |
| 66 | + { name: 'Jelly bean', calories: 400, fat: 0.0, carbs: 94, protein: 0.0, iron: 0 }, |
| 67 | + { name: 'Lollipop', calories: 400, fat: 0.2, carbs: 98, protein: 0, iron: 2 }, |
| 68 | + { name: 'Honeycomb', calories: 400, fat: 3.2, carbs: 87, protein: 6.5, iron: 45 }, |
| 69 | + { name: 'Donut', calories: 500, fat: 25.0, carbs: 51, protein: 4.9, iron: 22 }, |
| 70 | + { name: 'KitKat', calories: 500, fat: 26.0, carbs: 65, protein: 7, iron: 6 }, |
206 | 71 | ],
|
207 | 72 | }
|
208 | 73 | },
|
|
0 commit comments