From cd8f1be8399202babd223633d4459bb2b51b6c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=BB=E7=8F=BD?= Date: Tue, 25 Sep 2018 15:04:56 +0800 Subject: [PATCH] fixed bug #4466 #4300 --- examples/routers/select.vue | 7 +++++++ src/components/select/select.vue | 13 +++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/examples/routers/select.vue b/examples/routers/select.vue index 3ba4557d..725c9c1a 100644 --- a/examples/routers/select.vue +++ b/examples/routers/select.vue @@ -7,6 +7,8 @@ + + diff --git a/src/components/select/select.vue b/src/components/select/select.vue index 6461c68b..0e5a89b5 100644 --- a/src/components/select/select.vue +++ b/src/components/select/select.vue @@ -135,6 +135,15 @@ return textContent || (typeof innerHTML === 'string' ? innerHTML : ''); }; + const checkValuesNotEqual = (value,publicValue,values) => { + const strValue = JSON.stringify(value); + const strPublic = JSON.stringify(publicValue); + const strValues = JSON.stringify(values.map( item => { + return item.value; + })); + return strValue !== strPublic || strValue !== strValues || strValues !== strPublic; + }; + const ANIMATION_TIMEOUT = 300; @@ -653,12 +662,12 @@ }, watch: { value(value){ - const {getInitialValue, getOptionData, publicValue} = this; + const {getInitialValue, getOptionData, publicValue, values} = this; this.checkUpdateStatus(); if (value === '') this.values = []; - else if (JSON.stringify(value) !== JSON.stringify(publicValue)) { + else if (checkValuesNotEqual(value,publicValue,values)) { this.$nextTick(() => this.values = getInitialValue().map(getOptionData).filter(Boolean)); } },