滚动行为==良好的用户交互体验==功能使用前端路由,当切换到新路由时,您希望页面滚动到顶部,或者保持原来的滚动位置,就像重新加载一样这一页。vue-router可以做到,而且更好的是,它允许你自定义路由切换时页面如何滚动。注意此功能仅在HTML5历史记录模式下可用。具体方法实例constrouter=newVueRouter({routes:[...],scrollBehavior(to,from,savedPosition){//返回预期的滚动位置}})totheroutetogofromrouteobjecttoleavefromsavedPosition当且仅当popstate导航(由浏览器的前进/后退按钮触发)时可用。滚动行为传递的值是return后值的类型{x:number,y:number}{selector:string}string是to.hash值带#的小casehttps://hxj886600.github.io/v...
