在main.js中配置
router.afterEach((to, from, next) => {
window.scrollTo(0, 0)
})
或index.js配置
scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 }
}
都无效果,还有别的方法吗?各位大佬
在main.js中配置
router.afterEach((to, from, next) => {
window.scrollTo(0, 0)
})
或index.js配置
scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 }
}
都无效果,还有别的方法吗?各位大佬
加上一个定时器试试
router.afterEach((to, from, next) => {
setTimeout(function() {
window.scrollTo(0, 0)
},100)
})
9 回答1.8k 阅读✓ 已解决
6 回答1.8k 阅读
3 回答1.5k 阅读✓ 已解决
4 回答1.4k 阅读✓ 已解决
3 回答1.3k 阅读
2 回答1.3k 阅读✓ 已解决
3 回答1.5k 阅读✓ 已解决
试试这个