From e1b86bcf73a4664c315ff70a50934a57c095b10c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=81=8F?= Date: Thu, 14 Sep 2017 15:49:37 +0800 Subject: [PATCH] fixed #1865 --- examples/routers/select.vue | 112 ++++++++++++++++++++++++++----- src/components/select/option.vue | 6 +- src/components/select/select.vue | 1 + 3 files changed, 102 insertions(+), 17 deletions(-) diff --git a/examples/routers/select.vue b/examples/routers/select.vue index 6900d5bf..65606020 100644 --- a/examples/routers/select.vue +++ b/examples/routers/select.vue @@ -53,33 +53,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file + diff --git a/src/components/select/option.vue b/src/components/select/option.vue index 1adf7d9c..8dc23081 100644 --- a/src/components/select/option.vue +++ b/src/components/select/option.vue @@ -63,10 +63,14 @@ queryChange (val) { const parsedQuery = val.replace(/(\^|\(|\)|\[|\]|\$|\*|\+|\.|\?|\\|\{|\}|\|)/g, '\\$1'); this.hidden = !new RegExp(parsedQuery, 'i').test(this.searchLabel); + }, + // 在使用函数防抖后,设置 key 后,不更新组件了,导致SearchLabel 不更新 #1865 + updateSearchLabel () { + this.searchLabel = this.$el.innerHTML; } }, mounted () { - this.searchLabel = this.$el.innerHTML; + this.updateSearchLabel(); this.dispatch('iSelect', 'append'); this.$on('on-select-close', () => { this.isFocus = false; diff --git a/src/components/select/select.vue b/src/components/select/select.vue index bd132cf4..94105376 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -627,6 +627,7 @@ this.$nextTick(() => this.broadcastQuery('')); } else { this.findChild((child) => { + child.updateSearchLabel(); // #1865 child.selected = this.multiple ? this.model.indexOf(child.value) > -1 : this.model === child.value; }); }