Bootstrap

vue keepalive路由跳转保留离开时的位置,回到原页面时是在离开时的位置

与keepAlive结合,如果keepAlive的话,保存停留的位置:

 
 
scrollBehavior (to, from, savedPosition) {
     if (savedPosition) {
            return savedPosition
    } else {
        if (from.meta.keepAlive) {
          from.meta.savedPosition = document.body.scrollTop;
        }
        return { x: 0, y: to.meta.savedPosition ||0}
    }
}

注:mode:history

;