Commit 1e17564989ec6afebd29876b86de35faeaff788a
1 parent
e2a877c4
Input add @on-search event
Showing
2 changed files
with
11 additions
and
4 deletions
Show diff stats
examples/routers/input.vue
| ... | ... | @@ -129,11 +129,11 @@ |
| 129 | 129 | <Icon type="ios-aperture" slot="prefix" /> |
| 130 | 130 | </Input> |
| 131 | 131 | <br><br><br><br> |
| 132 | - <Input v-model="value" search enter-button style="width: 300px" /> | |
| 132 | + <Input v-model="value" search enter-button style="width: 300px" @on-search="hs" /> | |
| 133 | 133 | <br><br> |
| 134 | - <Input v-model="value" search style="width: 300px" /> | |
| 134 | + <Input v-model="value" search style="width: 300px" @on-search="hs" /> | |
| 135 | 135 | <br><br> |
| 136 | - <Input v-model="value" search enter-button="搜索" style="width: 300px" /> | |
| 136 | + <Input v-model="value" search enter-button="Search" style="width: 300px" @on-search="hs" /> | |
| 137 | 137 | </div> |
| 138 | 138 | </template> |
| 139 | 139 | <script> |
| ... | ... | @@ -148,6 +148,11 @@ |
| 148 | 148 | select2: 'com', |
| 149 | 149 | select3: 'day' |
| 150 | 150 | } |
| 151 | + }, | |
| 152 | + methods: { | |
| 153 | + hs (val) { | |
| 154 | + console.log(val); | |
| 155 | + } | |
| 151 | 156 | } |
| 152 | 157 | } |
| 153 | 158 | </script> | ... | ... |
src/components/input/input.vue
| ... | ... | @@ -218,6 +218,7 @@ |
| 218 | 218 | methods: { |
| 219 | 219 | handleEnter (event) { |
| 220 | 220 | this.$emit('on-enter', event); |
| 221 | + if (this.search) this.$emit('on-search', this.currentValue); | |
| 221 | 222 | }, |
| 222 | 223 | handleKeydown (event) { |
| 223 | 224 | this.$emit('on-keydown', event); |
| ... | ... | @@ -292,8 +293,9 @@ |
| 292 | 293 | this.$emit('on-change', e); |
| 293 | 294 | }, |
| 294 | 295 | handleSearch () { |
| 295 | - if (this.disable) return false; | |
| 296 | + if (this.disabled) return false; | |
| 296 | 297 | this.$refs.input.focus(); |
| 298 | + this.$emit('on-search', this.currentValue); | |
| 297 | 299 | } |
| 298 | 300 | }, |
| 299 | 301 | watch: { | ... | ... |