zoukankan      html  css  js  c++  java
  • 导航守卫。404页面设置

    全局导航守卫:(在router.js中添加)

    router.beforeEach((to,from,next)=>{
      if(to.name!=='login'){
        if(localStorage.getItem('userid')){
          next()
        }else{
          next('login')
        }
    }else{
        next()
    }
    })

    组件内导航守卫:(在组件内添加)

    beforeRouteEnter(to,form,next){
        if(localStorage.getItem('userid')){
          next()
        }else{
          alert('请先登录')
          next('login')
        }
      },

    404页面设置:(在router.js中设置)

    { //输错路由重定向到登陆页面
        path: "*",
        redirect: "404"
      }
  • 相关阅读:
    感想2
    感想1
    记录4
    记录3
    记录2
    记录1
    库存物资管理系统-测试
    开学测试
    大二下开学测试有感
    大二下周总结一
  • 原文地址:https://www.cnblogs.com/hy96/p/12196386.html
Copyright © 2011-2022 走看看