fix(select): options not memorized when options set async

This commit is contained in:
07akioni 2019-09-03 10:18:19 +08:00
parent 52286b1e5f
commit 726a9419d5

View File

@ -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
*/