vue 页面跳转还停留在原来高度
router.beforeEach((to, from, next) => {const tokenStr = window.sessionStorage.getItem('Tk_token');if(!tokenStr){if(to.path==='/user'|| to.path==='/cartShop'){next('/login');}...
·
router.beforeEach((to, from, next) => {
const tokenStr = window.sessionStorage.getItem('Tk_token');
if(!tokenStr){
if(to.path==='/user'|| to.path==='/cartShop'){
next('/login');
}else{
window.scroll(0, 0); // <= 这个
next();
}
}else{
window.scroll(0, 0);
next();
}
});
更多推荐
已为社区贡献5条内容
所有评论(0)