滚动行为

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}

    }

  }

})

转载于:https://www.cnblogs.com/jessicaWy/p/7256914.html

你可能感兴趣的:(滚动行为)