From 9c3a3e7d03404d4ac5c7c26040e4d5e78de88022 Mon Sep 17 00:00:00 2001 From: YikaJ <547179699@qq.com> Date: Thu, 9 Feb 2017 11:48:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Select=20=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit select组件如果有filterable属性,对model进行修改,选择框为空值。 --- src/components/select/select.vue | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 2d515b22..6a524aac 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -478,22 +478,25 @@ setQuery (query) { if (!this.filterable) return; this.query = query; + }, + modelToQuery() { + if (!this.multiple && this.filterable && this.model) { + this.findChild((child) => { + if (this.model === child.value) { + if (child.label) { + this.query = child.label; + } else if (child.searchLabel) { + this.query = child.searchLabel; + } else { + this.query = child.value; + } + } + }); + } } }, compiled () { - if (!this.multiple && this.filterable && this.model) { - this.findChild((child) => { - if (this.model === child.value) { - if (child.label) { - this.query = child.label; - } else if (child.searchLabel) { - this.query = child.searchLabel; - } else { - this.query = child.value; - } - } - }); - } + this.modelToQuery() this.updateOptions(true); document.addEventListener('keydown', this.handleKeydown); @@ -521,6 +524,7 @@ }, watch: { model () { + this.modelToQuery() if (this.multiple) { if (this.slotChangeDuration) { this.slotChangeDuration = false;