相信在利用路由跳转时都遇到过,打开的新页面是页面的底部而不是顶部。
我们可以用过修改解决这个问题。
export default new Router({
routes: [{
path: '/',
name: 'Index',
component: Index,
meta: {
keepalive: false,
}
}],
scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 }
}
})
可以在index.js中加入scrollBehavior方法来更改打开新页面的位置