页面之间跳转,打开新的一个页面显示在顶部
在main.js 中添加代码:
router.afterEach((to, from, next) => { window.scrollTo(0, 0) })
或者
在index.js里添加
export default new Router({ routes: [{...}], scrollBehavior(to, from,savedPosition) { return { x: 0, y: 0 } } })
页面之间跳转,打开新的一个页面显示在顶部
在main.js 中添加代码:
router.afterEach((to, from, next) => { window.scrollTo(0, 0) })
或者
在index.js里添加
export default new Router({ routes: [{...}], scrollBehavior(to, from,savedPosition) { return { x: 0, y: 0 } } })
转载于:https://www.cnblogs.com/yd-MM/p/9961930.html