1.app.vue
<keep-alive>
? ? <router-view v-if="$route.path == '/theme/classMeeting'"></router-view>
</keep-alive>
<router-view v-if="$route.path != '/theme/classMeeting'"></router-view>
2. 返回頁面
beforeRouteLeave(to, from, next) { //保存滾動(dòng)條元素div的scrollTop值
this.scrollY = document.getElementById('main').scrollTop
next()
},
activated() { //如果頁面有keep-alive緩存功能续搀,這個(gè)函數(shù)會(huì)觸發(fā)
document.getElementById('main').scrollTop = this.scrollY // 設(shè)置滾動(dòng)條位置
},