全局路由首位配置

全局路由首位配置

const router = new Router({    //声明router
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'Home',
      component: Home,
      meta: {
        is_login: true,
      }
    },
    {
      path: '/login',
      name: 'Login',
      component: Login
    },
  ]
})

router.beforeEach(
  (to, from, next) => {
    if (to.meta.is_login) {
      if (sessionStorage.getItem('username')) {
         next() 
      }
      else { 
        next({name:'Login',query:{redirect:to.fullPath}}) 
      }
    } else {
      next()
    }
  }

)

export default router
上一篇:Meta-4mCpred:一种基于序列的meta预测器,使用有效的特征表示进行精确的DNA 4mC位点预测


下一篇:go语言复制一个struct 对象