首页 > 其他 > 详细

NProgress的使用 及 路由 token 定向的使用

时间:2019-11-05 19:02:07      阅读:94      评论:0      收藏:0      [点我收藏+]

  主要配合路由生命周期使用

  实现一个进度条的效果

  使用方法:

    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‘);

    }

  }

NProgress的使用 及 路由 token 定向的使用

原文:https://www.cnblogs.com/shangjun6/p/11800376.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!