From f301c4a2df88af3b6eb15a5c30fc0d242e2ed653 Mon Sep 17 00:00:00 2001 From: zhangz Date: Fri, 21 Jun 2024 16:07:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=99=9A=E6=8B=9F=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E9=85=8D=E5=90=88keep-alive=EF=BC=8Cactive=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=81=A2=E5=A4=8D=E5=90=8E=E9=A1=B5=E9=9D=A2=E5=8D=A1?= =?UTF-8?q?=E9=A1=BF=E3=80=81=E5=86=85=E5=AD=98=E9=A3=99=E5=8D=87=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/table/src/methods.js | 12 +++++++----- packages/table/src/table.js | 2 +- packages/table/src/util.js | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/table/src/methods.js b/packages/table/src/methods.js index 62e1c6da8..209e1376d 100644 --- a/packages/table/src/methods.js +++ b/packages/table/src/methods.js @@ -1680,7 +1680,7 @@ const Methods = { /** * 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步) */ - refreshScroll () { + refreshScroll (clearVirtualScroll = true) { const { lastScrollLeft, lastScrollTop } = this const { $refs } = this const { tableBody, leftBody, rightBody, tableFooter } = $refs @@ -1690,7 +1690,7 @@ const Methods = { const tableFooterElem = tableFooter ? tableFooter.$el : null // 还原滚动条位置 if (lastScrollLeft || lastScrollTop) { - return restoreScrollLocation(this, lastScrollLeft, lastScrollTop) + return restoreScrollLocation(this, lastScrollLeft, lastScrollTop, clearVirtualScroll) } // 重置 setScrollTop(tableBodyElem, lastScrollTop) @@ -4353,7 +4353,7 @@ const Methods = { /** * 手动清除滚动相关信息,还原到初始状态 */ - clearScroll () { + clearScroll (clearVirtualScroll = true) { const { $refs, scrollXStore, scrollYStore } = this const { tableBody, rightBody, tableFooter } = $refs const tableBodyElem = tableBody ? tableBody.$el : null @@ -4371,8 +4371,10 @@ const Methods = { tableBodyElem.scrollTop = 0 tableBodyElem.scrollLeft = 0 } - scrollXStore.startIndex = 0 - scrollYStore.startIndex = 0 + if (clearVirtualScroll) { + scrollXStore.startIndex = 0 + scrollYStore.startIndex = 0 + } return this.$nextTick() }, /** diff --git a/packages/table/src/table.js b/packages/table/src/table.js index 6bcee1aca..2c5e8ed2c 100644 --- a/packages/table/src/table.js +++ b/packages/table/src/table.js @@ -913,7 +913,7 @@ export default { this.preventEvent(null, 'mounted') }, activated () { - this.recalculate().then(() => this.refreshScroll()) + this.recalculate().then(() => this.refreshScroll(false)) this.preventEvent(null, 'activated') }, deactivated () { diff --git a/packages/table/src/util.js b/packages/table/src/util.js index cec6954c3..aedf727b1 100644 --- a/packages/table/src/util.js +++ b/packages/table/src/util.js @@ -8,8 +8,8 @@ const lineOffsetSizes = { medium: 1 } -export function restoreScrollLocation (_vm, scrollLeft, scrollTop) { - return _vm.clearScroll().then(() => { +export function restoreScrollLocation (_vm, scrollLeft, scrollTop, clearVirtualScroll = true) { + return _vm.clearScroll(clearVirtualScroll).then(() => { if (scrollLeft || scrollTop) { // 重置最后滚动状态 _vm.lastScrollLeft = 0