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

@ -680,7 +680,7 @@
<br><br>
<Select v-model="model1" size="large" style="width:200px">
<Select v-model="model1" size="large" style="width:200px" clearable @on-clear="onClear">
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select>
<Select v-model="model10" size="large" multiple style="width:260px">
@ -761,6 +761,11 @@
model10: [],
model11: []
}
},
methods: {
onClear(){
console.log('onClear');
}
}
}
</script>

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){