Commit 7dbde804d8a85099c77dbbbf80133eec5a508af8

Authored by Sergio Crisostomo
1 parent d4f39edc

add on-clear event

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