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