From 726a9419d5dae466fe47a4dbe85d31e27f6640f8 Mon Sep 17 00:00:00 2001 From: 07akioni <07akioni2@gmail.com> Date: Tue, 3 Sep 2019 10:18:19 +0800 Subject: [PATCH] fix(select): options not memorized when options set async --- packages/common/Select/src/BaseSelect.vue | 29 +++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/packages/common/Select/src/BaseSelect.vue b/packages/common/Select/src/BaseSelect.vue index 6b4976a51..d1922f77f 100644 --- a/packages/common/Select/src/BaseSelect.vue +++ b/packages/common/Select/src/BaseSelect.vue @@ -200,6 +200,9 @@ export default { } }, watch: { + options () { + this.$nextTick().then(this.updateMemorizedOptions) + }, filteredOptions () { this.$nextTick().then(() => { this.updatePosition() @@ -221,18 +224,24 @@ export default { } }, mounted () { - if (this.remote && this.multiple) { - for (const option of this.selectedOptions) { - this.memorizedValueOptionMap.set(option.value, option) - } - } else if (this.remote && !this.multiple) { - const option = this.selectedOption - if (option) { - this.memorizedValueOptionMap.set(option.value, option) - } - } + this.updateMemorizedOptions() }, methods: { + /** + * remote related methods + */ + updateMemorizedOptions () { + if (this.remote && this.multiple) { + for (const option of this.selectedOptions) { + this.memorizedValueOptionMap.set(option.value, option) + } + } else if (this.remote && !this.multiple) { + const option = this.selectedOption + if (option) { + this.memorizedValueOptionMap.set(option.value, option) + } + } + }, /** * menu related methods */