add on-clear event

This commit is contained in:
Sergio Crisostomo 2018-05-08 12:47:03 +02:00
parent d4f39edc35
commit 7dbde804d8
3 changed files with 19 additions and 9 deletions

View file

@ -25,7 +25,7 @@
@blur="onInputFocus"
ref="input">
<Icon type="ios-close" :class="[prefixCls + '-arrow']" v-if="resetSelect" @click.native.stop="resetSelect"></Icon>
<Icon type="ios-close" :class="[prefixCls + '-arrow']" v-if="resetSelect" @click.native.stop="onClear"></Icon>
<Icon type="arrow-down-b" :class="[prefixCls + '-arrow']" v-if="!resetSelect && !remote && !disabled"></Icon>
</div>
</template>
@ -165,6 +165,9 @@
if (this.filterable && e.target === this.$el){
this.$refs.input.focus();
}
},
onClear(){
this.$emit('on-clear');
}
},
watch: {

View file

@ -42,6 +42,7 @@
@on-query-change="onQueryChange"
@on-input-focus="isFocused = true"
@on-input-blur="isFocused = false"
@on-clear="clearSingleSelect"
/>
</slot>
</div>
@ -382,6 +383,7 @@
}
},
clearSingleSelect(){ // PUBLIC API
this.$emit('on-clear');
if (this.clearable) this.values = [];
},
getOptionData(value){