1. export default new Router({
    2. mode: 'history',
    3. base: process.env.BASE_URL,
    4. routes: [
    5. {
    6. path: '/',
    7. name: 'home',
    8. component: Home
    9. },
    10. ],
    11. //配置这个
    12. scrollBehavior(to,from,savedPosition){
    13. console.log(to)
    14. if(to.path == "/detail"){
    15. return {x:0,y:0} //让页面处于顶部
    16. }else{
    17. return savedPosition //让页面处于记录点的位置
    18. }
    19. }
    20. })