vscode拦截器
再写登录页面的时候,即使不登录,也能根据连接跳转,为了阻止这个情况,所以使用了拦截器
{
path:'/myprofile',
name:'myprofile',
component:myprofile,
//拦截器器
beforeEnter: (to, from, next) => {
//如果登录过,停留在此页面
if(localStorage.getItem('username')){
console.log('已登录')
next()
//如果没有登录过,强制跳到其他页面
}else{
console.log('没有登录')
next('/login')
}
}
}
坚持,坚持,坚持……
在你选择不放弃的那一刻,
成功其实已经在向你走近
我们无法得知什么时候会来临
但我们可以选择用自强的双手敲开幸福的门。

浙公网安备 33010602011771号