Commit 721dc6915397f3f2e9b45ae8ff33738c6c4d14b3

Authored by Sergio Crisostomo
1 parent 1f41c9ca

fix debounce context

Showing 1 changed file with 16 additions and 14 deletions   Show diff stats
src/components/select/select.vue
... ... @@ -624,18 +624,20 @@
624 624 this.broadcast('iOption', 'on-query-change', val);
625 625 }
626 626 },
627   - debouncedAppendRemove: debounce(function(){
628   - if (!this.remote) {
629   - this.modelToQuery();
630   - this.$nextTick(() => this.broadcastQuery(''));
631   - } else {
632   - this.findChild((child) => {
633   - child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
634   - });
635   - }
636   - this.slotChange();
637   - this.updateOptions(true, true);
638   - }),
  627 + debouncedAppendRemove(){
  628 + return debounce(function(){
  629 + if (!this.remote) {
  630 + this.modelToQuery();
  631 + this.$nextTick(() => this.broadcastQuery(''));
  632 + } else {
  633 + this.findChild((child) => {
  634 + child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value;
  635 + });
  636 + }
  637 + this.slotChange();
  638 + this.updateOptions(true, true);
  639 + });
  640 + },
639 641 // 处理 remote 初始值
640 642 updateLabel () {
641 643 if (this.remote) {
... ... @@ -669,8 +671,8 @@
669 671 this.updateOptions(true);
670 672 document.addEventListener('keydown', this.handleKeydown);
671 673  
672   - this.$on('append', this.debouncedAppendRemove);
673   - this.$on('remove', this.debouncedAppendRemove);
  674 + this.$on('append', this.debouncedAppendRemove());
  675 + this.$on('remove', this.debouncedAppendRemove());
674 676  
675 677 this.$on('on-select-selected', (value) => {
676 678 if (this.model === value) {
... ...