-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseSelect.vue
59 lines (56 loc) · 1.37 KB
/
BaseSelect.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
<template>
<div>
<label class="label-style" :for="label" v-if="label">{{ label }}</label>
<!-- Using Default HTML select -->
<!-- <select
class="input-style"
:id="label"
:value="modelValue"
v-bind="{
...$attrs,
onInput: ($event) => {
$emit('update:modelValue', $event.target.value);
},
}"
:class="{ err: error }"
>
<option
:value="option"
v-for="option in options"
:key="option"
:selected="option === modelValue"
>
{{ option }}
</option>
</select> -->
<!-- Using vSelect -->
<v-select
class="v-style"
:class="{ err: error }"
label="option"
:value="modelValue"
:options="options"
v-bind="{
...$attrs,
onInput: ($event: Event) => {
$emit('update:modelValue', ($event.target as HTMLInputElement).value);
},
}"
></v-select>
<small :class="{ 'err-message': error }" v-if="error"
>{{ label }} is required</small
>
</div>
</template>
<script setup lang="ts">
import vSelect from "vue-select"
interface Props {
label?: string,
modelValue: string | number,
error?: string | boolean,
options: (string | number)[],
}
const emit = defineEmits(['changeType', 'update:modelValue'])
defineProps<Props>();
</script>
<style lang="scss" scoped></style>