首页 > 其他 > 详细

dva 路由权鉴

时间:2019-01-28 23:33:16      阅读:282      评论:0      收藏:0      [点我收藏+]

在路由文件router下

  history.listen(location => {
        const uid = sessionStorage.getItem(‘uid‘) || localStorage.getItem("uid")
        console.log(location.pathname)
        if (location.pathname === ‘/‘ || location.pathname === ‘/login‘) {
            if (uid) {
                app._store.dispatch(routerRedux.replace(‘/backstage‘))
              }
        }else{
            if(!uid){
                app._store.dispatch(routerRedux.push(‘/‘))
            }
        }

添加全局的路由监听。然后判断跳转。

这里只能判断本地的路由登录情况,如果token过期了无法判断

dva 路由权鉴

原文:https://www.cnblogs.com/unreal-feather/p/10332151.html

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