滚动行为

new router({

  scrollBehavior (to, from, savaPosition) {

    if(savePosition) {       //历史记录的前进后退记住的之前滚动到的位置

      return savePosition

    } else {

      return {x: 0, y: 0}

    }

//history模式下 定位到某个元素失效的解决办法

    if(to.hash) {

      return {

        selector: to.hash

      }

    } else {

      return {x: 0, y: 0}

    }

  }

})

posted @ 2017-07-29 17:39  啊友的前端历程  阅读(150)  评论(0编辑  收藏  举报