-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathExampleDynamicOptions.vue
43 lines (41 loc) · 1.21 KB
/
ExampleDynamicOptions.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
<script setup lang="ts">
import { ref } from 'vue'
import {
VueScrollPicker,
VueScrollPickerOptionable,
VueScrollPickerValue,
} from 'vue-scroll-picker'
import CurrentValue from './CurrentValue.vue'
const options = ref<VueScrollPickerOptionable<number>[]>([])
const currentValue = ref<VueScrollPickerValue>(null)
function pushItem() {
options.value.push(~~(Math.random() * 100000))
}
function popItem() {
options.value.pop()
}
function unshiftItem() {
options.value.unshift(~~(Math.random() * 100000))
}
function shiftItem() {
options.value.shift()
}
function replaceItems() {
options.value = [...new Array(10)].map(() => ~~(Math.random() * 100000))
}
</script>
<template>
<div>
<div class="controller">
<CurrentValue :value="currentValue" />
<div class="button-group">
<a class="button" @click="pushItem">Push Random Item</a>
<a class="button" @click="popItem">Pop Item</a>
<a class="button" @click="unshiftItem">Unshift Random Item</a>
<a class="button" @click="shiftItem">Shift Item</a>
<a class="button" @click="replaceItems">Replace 10 Items</a>
</div>
</div>
<VueScrollPicker v-model="currentValue" :options="options" />
</div>
</template>