From 485f536a547cf02745cc289913a8fa0d79088ac6 Mon Sep 17 00:00:00 2001 From: violarong Date: Thu, 1 Dec 2022 17:59:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:bug:=20UTableView=20=E5=9C=A8=E6=9F=90?= =?UTF-8?q?=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8B=E7=88=B6=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BA=86min-width:fit-content=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8ChandleResize=E4=BC=9A?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/u-table-view.vue/index.vue | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/u-table-view.vue/index.vue b/src/components/u-table-view.vue/index.vue index 7a2783745..ea32d5595 100644 --- a/src/components/u-table-view.vue/index.vue +++ b/src/components/u-table-view.vue/index.vue @@ -599,7 +599,8 @@ export default { this.watchValue(this.value); this.watchValues(this.values); this.handleResize(); - addResizeListener(this.$el, this.handleResize); + this.preRootWidth = undefined; + addResizeListener(this.$el, this.handleResizeListener); if (this.stickHead) { this.scrollParentEl = findScrollParent(this.$el); @@ -607,11 +608,12 @@ export default { } }, destroyed() { - removeResizeListener(this.$el, this.handleResize); + removeResizeListener(this.$el, this.handleResizeListener); if (this.stickHead) { this.scrollParentEl && this.scrollParentEl.removeEventListener('scroll', this.onScrollParentScroll); } this.clearTimeout(); + this.preRootWidth = undefined; }, methods: { typeCheck(type) { @@ -714,7 +716,7 @@ export default { number2Pixel(value) { return isNumber(value) ? value + 'px' : ''; }, - handleResize() { + handleResize(isListener) { if (this.resizeBodyHeight) { this.bodyHeight = undefined; } @@ -730,6 +732,17 @@ export default { parentEl = parentEl.parentElement; rootWidth = parentEl ? parentEl.offsetWidth : 0; } + // 有些情况下rootWidth会缓慢增长,导致handleResize一直执行 + if (isListener) { + if (!this.preRootWidth) { + this.preRootWidth = rootWidth; + } else { + if (Math.abs(this.preRootWidth - rootWidth) <= 1) { + return; + } + this.preRootWidth = rootWidth; + } + } // 分别获取有百分比、具体数值和无 width 的列 const percentColumnVMs = []; @@ -2002,6 +2015,9 @@ export default { } return '100%'; }, + handleResizeListener() { + this.handleResize(true); + }, }, }; From 5b50aa9cd1be8146dd1f7ad460d96acf0424dd47 Mon Sep 17 00:00:00 2001 From: violarong Date: Fri, 2 Dec 2022 09:47:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:bug:=20UTableView=20=E5=9C=A8=E6=9F=90?= =?UTF-8?q?=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8B=E7=88=B6=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BA=86min-width:fit-content=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8ChandleResize=E4=BC=9A?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/u-table-view.vue/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/u-table-view.vue/index.vue b/src/components/u-table-view.vue/index.vue index ea32d5595..04d568df3 100644 --- a/src/components/u-table-view.vue/index.vue +++ b/src/components/u-table-view.vue/index.vue @@ -738,7 +738,7 @@ export default { this.preRootWidth = rootWidth; } else { if (Math.abs(this.preRootWidth - rootWidth) <= 1) { - return; + rootWidth = this.preRootWidth; } this.preRootWidth = rootWidth; }