与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

Logo

前往低代码交流专区

更多推荐