解决vue路由跳转页面时显示的是页面的底部
相信在利用路由跳转时都遇到过,打开的新页面是页面的底部而不是顶部。我们可以用过修改解决这个问题。export default new Router({routes: [{path: '/',name: 'Index',component: Index,meta: {keepalive: false,}}],scr...
·
相信在利用路由跳转时都遇到过,打开的新页面是页面的底部而不是顶部。
我们可以用过修改解决这个问题。
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方法来更改打开新页面的位置
更多推荐



所有评论(0)