Commit a73ae72b3559eb3abf4420ad835931c003b76c82
1 parent
07614811
fixed #2884
Showing
3 changed files
with
32 additions
and
6 deletions
Show diff stats
examples/routers/input.vue
| 1 | 1 | <template> |
| 2 | - <div style="width: 300px"> | |
| 3 | - <Input v-model="value7" type="textarea" :autosize="true" placeholder="Enter something..."></Input> | |
| 4 | - <Input v-model="value8" type="textarea" :autosize="{minRows: 2,maxRows: 5}" placeholder="Enter something..."></Input> | |
| 2 | + <div> | |
| 3 | + {{ value1 }} | |
| 4 | + <Input v-model="value1" clearable icon="ios-clock-outline" size="large" placeholder="large size"></Input> | |
| 5 | + <br> | |
| 6 | + <Input v-model="value2" clearable placeholder="default size"></Input> | |
| 7 | + <br> | |
| 8 | + <Input v-model="value3" clearable size="small" placeholder="small size"></Input> | |
| 5 | 9 | </div> |
| 6 | 10 | </template> |
| 7 | 11 | <script> |
| 8 | 12 | export default { |
| 9 | 13 | data () { |
| 10 | 14 | return { |
| 11 | - value7: '', | |
| 12 | - value8: '' | |
| 15 | + value1: '', | |
| 16 | + value2: '', | |
| 17 | + value3: '' | |
| 13 | 18 | } |
| 14 | 19 | } |
| 15 | 20 | } | ... | ... |
src/components/input/input.vue
| ... | ... | @@ -2,7 +2,8 @@ |
| 2 | 2 | <div :class="wrapClasses"> |
| 3 | 3 | <template v-if="type !== 'textarea'"> |
| 4 | 4 | <div :class="[prefixCls + '-group-prepend']" v-if="prepend" v-show="slotReady"><slot name="prepend"></slot></div> |
| 5 | - <i class="ivu-icon" :class="['ivu-icon-' + icon, prefixCls + '-icon', prefixCls + '-icon-normal']" v-if="icon" @click="handleIconClick"></i> | |
| 5 | + <i class="ivu-icon" :class="['ivu-icon-ios-close', prefixCls + '-icon', prefixCls + '-icon-clear' , prefixCls + '-icon-normal']" v-if="clearable" @click="handleClear"></i> | |
| 6 | + <i class="ivu-icon" :class="['ivu-icon-' + icon, prefixCls + '-icon', prefixCls + '-icon-normal']" v-else-if="icon" @click="handleIconClick"></i> | |
| 6 | 7 | <transition name="fade"> |
| 7 | 8 | <i class="ivu-icon ivu-icon-load-c ivu-load-loop" :class="[prefixCls + '-icon', prefixCls + '-icon-validate']" v-if="!icon"></i> |
| 8 | 9 | </transition> |
| ... | ... | @@ -128,6 +129,10 @@ |
| 128 | 129 | }, |
| 129 | 130 | default: 'off' |
| 130 | 131 | }, |
| 132 | + clearable: { | |
| 133 | + type: Boolean, | |
| 134 | + default: false | |
| 135 | + }, | |
| 131 | 136 | elementId: { |
| 132 | 137 | type: String |
| 133 | 138 | } |
| ... | ... | @@ -244,6 +249,12 @@ |
| 244 | 249 | } else { |
| 245 | 250 | this.$refs.input.blur(); |
| 246 | 251 | } |
| 252 | + }, | |
| 253 | + handleClear () { | |
| 254 | + const e = { target: { value: '' } }; | |
| 255 | + this.$emit('input', ''); | |
| 256 | + this.setCurrentValue(''); | |
| 257 | + this.$emit('on-change', e); | |
| 247 | 258 | } |
| 248 | 259 | }, |
| 249 | 260 | watch: { | ... | ... |
src/styles/components/input.less