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,11 +129,11 @@ | ||
| 129 | <Icon type="ios-aperture" slot="prefix" /> | 129 | <Icon type="ios-aperture" slot="prefix" /> |
| 130 | </Input> | 130 | </Input> |
| 131 | <br><br><br><br> | 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 | <br><br> | 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 | <br><br> | 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 | </div> | 137 | </div> |
| 138 | </template> | 138 | </template> |
| 139 | <script> | 139 | <script> |
| @@ -148,6 +148,11 @@ | @@ -148,6 +148,11 @@ | ||
| 148 | select2: 'com', | 148 | select2: 'com', |
| 149 | select3: 'day' | 149 | select3: 'day' |
| 150 | } | 150 | } |
| 151 | + }, | ||
| 152 | + methods: { | ||
| 153 | + hs (val) { | ||
| 154 | + console.log(val); | ||
| 155 | + } | ||
| 151 | } | 156 | } |
| 152 | } | 157 | } |
| 153 | </script> | 158 | </script> |
src/components/input/input.vue
| @@ -218,6 +218,7 @@ | @@ -218,6 +218,7 @@ | ||
| 218 | methods: { | 218 | methods: { |
| 219 | handleEnter (event) { | 219 | handleEnter (event) { |
| 220 | this.$emit('on-enter', event); | 220 | this.$emit('on-enter', event); |
| 221 | + if (this.search) this.$emit('on-search', this.currentValue); | ||
| 221 | }, | 222 | }, |
| 222 | handleKeydown (event) { | 223 | handleKeydown (event) { |
| 223 | this.$emit('on-keydown', event); | 224 | this.$emit('on-keydown', event); |
| @@ -292,8 +293,9 @@ | @@ -292,8 +293,9 @@ | ||
| 292 | this.$emit('on-change', e); | 293 | this.$emit('on-change', e); |
| 293 | }, | 294 | }, |
| 294 | handleSearch () { | 295 | handleSearch () { |
| 295 | - if (this.disable) return false; | 296 | + if (this.disabled) return false; |
| 296 | this.$refs.input.focus(); | 297 | this.$refs.input.focus(); |
| 298 | + this.$emit('on-search', this.currentValue); | ||
| 297 | } | 299 | } |
| 298 | }, | 300 | }, |
| 299 | watch: { | 301 | watch: { |