A vue 2.0 directive to keep scroll position for keep-alived components. Forked from vue-keep-scroll and rewritten for vue 2.0 compatibility.
npm i -S vue-keep-scroll-position
import Vue from 'vue'
import VueKeepScrollPosition from 'vue-keep-scroll-position'
Vue.use VueKeepScrollPosition
Just add v-keep-scroll-position
to your components within <keep-alive>
. For router-view
:
<keep-alive>
<router-view v-keep-scroll-position></router-view>
</keep-alive>
For simple dynamic components:
<keep-alive>
<component :is="someComponentName" v-keep-scroll-position></component>
</keep-alive>