1.局部设置用法:
在跳转的新组件中添加如下代码
methods:{
mounted(){
this.$router.afterEach((to, from) => {
window.scrollTo(0, 0)
}
}
2.全局设置
在main.js插入代码
router.afterEach((to,from,next)=>{
window.scrollTo(0,0)
})
1.局部设置用法:
在跳转的新组件中添加如下代码
methods:{
mounted(){
this.$router.afterEach((to, from) => {
window.scrollTo(0, 0)
}
}
2.全局设置
在main.js插入代码
router.afterEach((to,from,next)=>{
window.scrollTo(0,0)
})