Skip to content

Commit 0e1f10c

Browse files
JungJooJungJoo
authored andcommitted
Merge branch 'model-select-number-type'
2 parents b674f73 + 68445f6 commit 0e1f10c

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

src/components/lib/ModelSelect.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
type: Array
4848
},
4949
value: {
50-
type: [String, Object]
50+
type: [String, Number, Object]
5151
}
5252
},
5353
data () {
@@ -108,7 +108,7 @@
108108
optionValue () {
109109
if (typeof this.value === 'object') {
110110
return this.value.value
111-
} else if (typeof this.value === 'string') {
111+
} else {
112112
return this.value
113113
}
114114
},
@@ -157,7 +157,7 @@
157157
this.closeOptions()
158158
if (typeof this.value === 'object') {
159159
this.$emit('input', option)
160-
} else if (typeof this.value === 'string') {
160+
} else {
161161
this.$emit('input', option.value)
162162
}
163163
}

src/components/sample/Model/Model.vue

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<div>
3+
<h3>Object type model</h3>
34
<div class="flexbox">
45
<div class="flex-content">
56
<div>
@@ -32,6 +33,7 @@
3233
</table>
3334
</div>
3435
</div>
36+
<h3>String type model</h3>
3537
<div class="flexbox">
3638
<div class="flex-content">
3739
<div>
@@ -62,6 +64,37 @@
6264
</table>
6365
</div>
6466
</div>
67+
<h3>Number type model</h3>
68+
<div class="flexbox">
69+
<div class="flex-content">
70+
<div>
71+
<button type="button" @click="reset3" class="btn btn-info btn-sm">reset</button>
72+
</div>
73+
<div>
74+
<button type="button" @click="selectOption3" class="btn btn-info btn-sm">option select from parent</button>
75+
</div>
76+
<div>
77+
<model-select :options="options3"
78+
v-model="item3"
79+
placeholder="select item3">
80+
</model-select>
81+
</div>
82+
</div>
83+
<div class="flex-result">
84+
<table class="ui celled table">
85+
<thead>
86+
<tr>
87+
<th>value</th>
88+
</tr>
89+
</thead>
90+
<tbody>
91+
<tr>
92+
<td>{{item3}}</td>
93+
</tr>
94+
</tbody>
95+
</table>
96+
</div>
97+
</div>
6598
</div>
6699
</template>
67100

@@ -121,7 +154,13 @@
121154
{ value: '23', text: 'more a' + ' - ' + '8' },
122155
{ value: '24', text: 'more a' + ' - ' + '9' }
123156
],
124-
item2: ''
157+
item2: '',
158+
options3: [
159+
{ value: 0, text: 'aa' + ' - ' + '0' },
160+
{ value: 1, text: 'aa' + ' - ' + '1' },
161+
{ value: 2, text: 'ab' + ' - ' + '2' }
162+
],
163+
item3: 0
125164
}
126165
},
127166
methods: {
@@ -138,6 +177,13 @@
138177
selectOption2 () {
139178
// select option from parent component
140179
this.item2 = this.options2[0].value
180+
},
181+
reset3 () {
182+
this.item3 = ''
183+
},
184+
selectOption3 () {
185+
// select option from parent component
186+
this.item3 = this.options3[0].value
141187
}
142188
},
143189
components: {

0 commit comments

Comments
 (0)