Commit 7dbde804d8a85099c77dbbbf80133eec5a508af8

Authored by Sergio Crisostomo
1 parent d4f39edc

add on-clear event

examples/routers/select.vue
@@ -671,16 +671,16 @@ @@ -671,16 +671,16 @@
671 671
672 <template> 672 <template>
673 <div> 673 <div>
674 - <Select v-model="model1" size="small" style="width:200px;"> 674 + <Select v-model="model1" size="small" style="width:200px;" >
675 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> 675 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
676 </Select> 676 </Select>
677 - <Select v-model="model10" size="small" multiple style="width:260px"> 677 + <Select v-model="model10" size="small" multiple style="width:260px" >
678 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> 678 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
679 </Select> 679 </Select>
680 680
681 <br><br> 681 <br><br>
682 682
683 - <Select v-model="model1" size="large" style="width:200px"> 683 + <Select v-model="model1" size="large" style="width:200px" clearable @on-clear="onClear">
684 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> 684 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
685 </Select> 685 </Select>
686 <Select v-model="model10" size="large" multiple style="width:260px"> 686 <Select v-model="model10" size="large" multiple style="width:260px">
@@ -698,11 +698,11 @@ @@ -698,11 +698,11 @@
698 <Select v-model="model10" multiple style="width:260px"> 698 <Select v-model="model10" multiple style="width:260px">
699 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> 699 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
700 </Select> 700 </Select>
701 - 701 +
702 <br><br> 702 <br><br>
703 - 703 +
704 <br><br> 704 <br><br>
705 - 705 +
706 <br><br> 706 <br><br>
707 <br><br> 707 <br><br>
708 <br><br> 708 <br><br>
@@ -713,9 +713,9 @@ @@ -713,9 +713,9 @@
713 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option> 713 <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
714 </Select> 714 </Select>
715 <br><br> 715 <br><br>
716 - 716 +
717 <br><br> 717 <br><br>
718 - 718 +
719 <br><br> 719 <br><br>
720 <br><br> 720 <br><br>
721 <br><br> 721 <br><br>
@@ -761,6 +761,11 @@ @@ -761,6 +761,11 @@
761 model10: [], 761 model10: [],
762 model11: [] 762 model11: []
763 } 763 }
  764 + },
  765 + methods: {
  766 + onClear(){
  767 + console.log('onClear');
  768 + }
764 } 769 }
765 } 770 }
766 </script> 771 </script>
src/components/select/select-head.vue
@@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
25 @blur="onInputFocus" 25 @blur="onInputFocus"
26 26
27 ref="input"> 27 ref="input">
28 - <Icon type="ios-close" :class="[prefixCls + '-arrow']" v-if="resetSelect" @click.native.stop="resetSelect"></Icon> 28 + <Icon type="ios-close" :class="[prefixCls + '-arrow']" v-if="resetSelect" @click.native.stop="onClear"></Icon>
29 <Icon type="arrow-down-b" :class="[prefixCls + '-arrow']" v-if="!resetSelect && !remote && !disabled"></Icon> 29 <Icon type="arrow-down-b" :class="[prefixCls + '-arrow']" v-if="!resetSelect && !remote && !disabled"></Icon>
30 </div> 30 </div>
31 </template> 31 </template>
@@ -165,6 +165,9 @@ @@ -165,6 +165,9 @@
165 if (this.filterable && e.target === this.$el){ 165 if (this.filterable && e.target === this.$el){
166 this.$refs.input.focus(); 166 this.$refs.input.focus();
167 } 167 }
  168 + },
  169 + onClear(){
  170 + this.$emit('on-clear');
168 } 171 }
169 }, 172 },
170 watch: { 173 watch: {
src/components/select/select.vue
@@ -42,6 +42,7 @@ @@ -42,6 +42,7 @@
42 @on-query-change="onQueryChange" 42 @on-query-change="onQueryChange"
43 @on-input-focus="isFocused = true" 43 @on-input-focus="isFocused = true"
44 @on-input-blur="isFocused = false" 44 @on-input-blur="isFocused = false"
  45 + @on-clear="clearSingleSelect"
45 /> 46 />
46 </slot> 47 </slot>
47 </div> 48 </div>
@@ -382,6 +383,7 @@ @@ -382,6 +383,7 @@
382 } 383 }
383 }, 384 },
384 clearSingleSelect(){ // PUBLIC API 385 clearSingleSelect(){ // PUBLIC API
  386 + this.$emit('on-clear');
385 if (this.clearable) this.values = []; 387 if (this.clearable) this.values = [];
386 }, 388 },
387 getOptionData(value){ 389 getOptionData(value){