主要配合路由生命周期使用
实现一个进度条的效果
使用方法:
1. 下载:npm install --save nprogress
使用:NProgress.start(); 开始
NProgress.done(); 停止
在 router 中使用路由守卫
token 重定向的使用
router.beforeEach(to, from, next){
const isLogin = localStorage.eleToken ? true : false;
if (to.path == ‘/login‘ || to.path == ‘/register‘){
next();
}
else {
isLogin ? next() : next(‘/login‘);
}
}
原文:https://www.cnblogs.com/shangjun6/p/11800376.html