Is there a way to keep the scroll position when switching between Tab Panels? #10036
-
I have two Tab Panels which each show a list of items. I want to use this on my home page but the problem I have is when switching between the Panels, the scroll position is lost. When you scroll in a panel, switch to another panel, and switch back to the first panel, the panel scroll position jumps back to the top. I have used "keep-alive" attribute but didn't do anything. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Panels are destroyed when switched unless you use |
Beta Was this translation helpful? Give feedback.
-
I used keep-alive, but when I click on tabs, window jump to top of page! when I open "inspect element" and shrinking the height of screen, problem solve! also when remove the "animated" problem solve... |
Beta Was this translation helpful? Give feedback.
Panels are destroyed when switched unless you use
keep-alive
. If you don't use this property, then you can useonBeforeUnmount
method to save the current position. Save the data outside of your component but within the<script>
tags. In theonMounted
method, check if the value is > 0 and set scroll offset appropriately.