1.缓存列表页
<keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive>
- 列表页进入详情页
离开列表页前,先获取到当前滚动条位置
beforeRouteLeave(to, from, next) {
let app = document.getElementById('app')
this.homeTop = app.scrollTop || 0
next()
},
3.详情页返回列表页
activated() {
document.getElementById('app').scrollTop = this.homeTop
}