Subscribe on changes!

Scroll bar is affected by keep alive or other pages?

avatar
Feb 2nd 2021

Version

3.0.5

Reproduction link

https://github.com/showyoulove/snowrunner.git

Steps to reproduce

npm i npm run serve

First scroll the scroll bar of the home page Then scroll the other page scroll bar Go back the home page You can see the position of the scroll bar is different

What is expected?

The scroll bar should keep the previous position

What is actually happening?

It seems to be affected by other pages

avatar
Feb 2nd 2021

Minimum reproduction please.

avatar
Feb 2nd 2021

Minimum reproduction please.

How? Single page can not reflect the problem

avatar
Feb 2nd 2021

A minimal reproduction doesn't mean "a single page". It means "the minimum amount of code necessary to demonstrate the problem".

A compete app with vuex, icons, a complete 3rd party framework (elements-plus) it definitely not the minimum amount of code necessary here.

Please try to narrow down your problem. You can also ask for help on chat.vuejs.org first.

avatar
Feb 2nd 2021
<router-view v-slot="{ Component }">
  <keep-alive>
    <component :is="Component"/>
  </keep-alive>
</router-view>
APP.vue
<div id="_layout">
   <el-affix>
     <nav-bar></nav-bar>
   </el-affix>
   <div class="main-section">
     <router-view v-slot="{ Component }">
       <keep-alive exclude="vehicles-details">
         <component :is="Component"/>
       </keep-alive>
     </router-view>
   </div>
 </div>
layout.vue
const routes = [
  {
    path: '/',
    name: 'Home',
    component: () => import(/* webpackChunkName: "layout" */ '@/layout/index'),
    children: [
      {
        path: '',
        name: 'home',
        component: () => import(/* webpackChunkName: "home" */ '@/views/Home'),
        meta: { title: '้ฆ–้กต' }
      },
    ]
  },
]
router
avatar
Feb 2nd 2021

@showyoulove please read https://new-issue.vuejs.org/?repo=vuejs/vue#why-repro To control scroll behavior you should use https://next.router.vuejs.org/guide/advanced/scroll-behavior.html#scroll-behavior


Please, next time consider using the forum, the Discord server or StackOverflow for questions first. But feel free to come back and open an issue if it turns out to be a bug ๐Ÿ™‚