Skip to content

Commit e818a90

Browse files
committed
Add same alu, other text generator
1 parent 74f2380 commit e818a90

File tree

1 file changed

+55
-5
lines changed

1 file changed

+55
-5
lines changed

demo/Demo.vue

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,11 @@
261261
<table class="demo__table">
262262
<tr class="table__table-row">
263263
<th class="demo__table-cell">d-val1</th>
264+
<th class="demo__table-cell">d-val2</th>
264265
</tr>
265266
<tr class="table__table-row">
266267
<td class="demo__table-cell">{{ dynVal1 }}</td>
268+
<td class="demo__table-cell">{{ dynVal2 }}</td>
267269
</tr>
268270
</table>
269271
</div>
@@ -299,6 +301,38 @@
299301
<button type="button" @click="genDynOpts1()">Re-generate d-val1</button>
300302
</div>
301303
</div>
304+
305+
<div class="demo__units">
306+
<div class="demo__unit">
307+
<p class="demo__lbl">Default select (d-val2)</p>
308+
<select class="demo__picker" v-model="dynVal2">
309+
<option value="">Empty</option>
310+
<option v-for="opt of dynOpts2" :key="opt.value" :value="opt.value">
311+
{{ opt.text }}
312+
</option>
313+
</select>
314+
</div>
315+
316+
<div class="demo__unit">
317+
<p class="demo__lbl">Custom select (d-val2)</p>
318+
<VuePicker class="demo__picker" v-model="dynVal2">
319+
<VuePickerOption value="">Empty</VuePickerOption>
320+
<VuePickerOption
321+
v-for="(opt, idx) in dynOpts2"
322+
:key="opt.value"
323+
:value="opt.value"
324+
:data-idx="idx"
325+
>
326+
{{ opt.text }}
327+
</VuePickerOption>
328+
</VuePicker>
329+
</div>
330+
331+
<div class="demo__unit">
332+
<p class="demo__lbl">Actions</p>
333+
<button type="button" @click="genDynOpts2()">Re-generate d-val2</button>
334+
</div>
335+
</div>
302336
</div>
303337
</template>
304338

@@ -307,13 +341,15 @@ import { ref } from 'vue'
307341
308342
export default {
309343
setup () {
310-
const _randOptions = () => {
311-
const len = _randInt(3, 5)
312-
const suf = String(_randInt(3, 5))
313-
344+
const _randOptions = (
345+
suf = String(_randInt(1, 25)),
346+
len = _randInt(1, 25),
347+
getValue = (suf, idx) => `val-${suf}-${idx}`,
348+
getText = (suf, idx) => `Value-${suf} #${idx}`,
349+
) => {
314350
const options = []
315351
for (let idx = 0; idx < len; idx++) {
316-
options.push({ value: `val-${suf}-${idx}`, text: `Value-${suf} #${idx}` })
352+
options.push({ value: getValue(suf, idx), text: getText(suf, idx) })
317353
}
318354
console.log('Generated options:', options)
319355
return options
@@ -330,6 +366,16 @@ export default {
330366
dynVal1.value = undefined
331367
}
332368
369+
let _dynVal2Counter = 0
370+
const dynOpts2 = ref(_randOptions('X', 8, undefined))
371+
const dynVal2 = ref(undefined)
372+
const genDynOpts2 = () => {
373+
_dynVal2Counter++
374+
dynOpts2.value = _randOptions('X', 8, undefined, (suf, idx) => {
375+
return `New (${_dynVal2Counter}) Value #${idx}`
376+
})
377+
}
378+
333379
return {
334380
selVal1: ref(undefined),
335381
selVal2: ref('val-2'),
@@ -341,6 +387,10 @@ export default {
341387
dynOpts1,
342388
dynVal1,
343389
genDynOpts1,
390+
391+
dynOpts2,
392+
dynVal2,
393+
genDynOpts2,
344394
}
345395
}
346396
}

0 commit comments

Comments
 (0)