【发布时间】:2021-04-26 23:02:00
【问题描述】:
我有以下问题: 当我单击新组件链接时,路由器视图不会滚动到 0,0,但会保持旧组件的滚动状态。它应该移动到顶部,但它没有......
这是我在 vue 中的路由器
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes,
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return { x: 0, y: 0 }
}
}
})
感谢您的帮助!
【问题讨论】:
标签: vue.js vue-router