From 3db31406a816dafe9863be70d37bbbbf1ebeb67e Mon Sep 17 00:00:00 2001 From: webpack Date: Tue, 21 Jul 2020 14:26:07 +0800 Subject: [PATCH] dropdown.vue: fix Pooper created multiple times Fix the issue that the select component watch selectOptions causes Pooper to repeatedly create multiple times (the bound scroll event cannot be cleared), and the select component watch selectOptions is recommended to be throttled. --- src/components/select/dropdown.vue | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/components/select/dropdown.vue b/src/components/select/dropdown.vue index c36bb286..5ff62e19 100644 --- a/src/components/select/dropdown.vue +++ b/src/components/select/dropdown.vue @@ -44,14 +44,13 @@ methods: { update () { if (isServer) return; - if (this.popper) { - this.$nextTick(() => { + this.$nextTick(() => { + if (this.popper) { this.popper.update(); this.popperStatus = true; - }); - } else { - this.$nextTick(() => { + } else { this.popper = new Popper(this.$parent.$refs.reference, this.$el, { + eventsEnabled: false, placement: this.placement, modifiers: { computeStyle:{ @@ -69,13 +68,13 @@ this.resetTransformOrigin(); } }); - }); - } - // set a height for parent is Modal and Select's width is 100% - if (this.$parent.$options.name === 'iSelect') { - this.width = parseInt(getStyle(this.$parent.$el, 'width')); - } - this.tIndex = this.handleGetIndex(); + } + // set a height for parent is Modal and Select's width is 100% + if (this.$parent.$options.name === 'iSelect') { + this.width = parseInt(getStyle(this.$parent.$el, 'width')); + } + this.tIndex = this.handleGetIndex(); + }); }, destroy () { if (this.popper) {