From 721dc6915397f3f2e9b45ae8ff33738c6c4d14b3 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Fri, 8 Sep 2017 08:19:04 +0200 Subject: [PATCH] fix debounce context --- src/components/select/select.vue | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 5a59ff4..d6bc8d6 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -624,18 +624,20 @@ this.broadcast('iOption', 'on-query-change', val); } }, - debouncedAppendRemove: debounce(function(){ - if (!this.remote) { - this.modelToQuery(); - this.$nextTick(() => this.broadcastQuery('')); - } else { - this.findChild((child) => { - child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value; - }); - } - this.slotChange(); - this.updateOptions(true, true); - }), + debouncedAppendRemove(){ + return debounce(function(){ + if (!this.remote) { + this.modelToQuery(); + this.$nextTick(() => this.broadcastQuery('')); + } else { + this.findChild((child) => { + child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value; + }); + } + this.slotChange(); + this.updateOptions(true, true); + }); + }, // 处理 remote 初始值 updateLabel () { if (this.remote) { @@ -669,8 +671,8 @@ this.updateOptions(true); document.addEventListener('keydown', this.handleKeydown); - this.$on('append', this.debouncedAppendRemove); - this.$on('remove', this.debouncedAppendRemove); + this.$on('append', this.debouncedAppendRemove()); + this.$on('remove', this.debouncedAppendRemove()); this.$on('on-select-selected', (value) => { if (this.model === value) { -- libgit2 0.21.4