路由需要配置出口

路由守卫

  1. {
  2. path:'/study',
  3. component: () => import("../views/study.vue"),
  4. beforeEnter(to,from,next){
  5. let res = localStorage.getItem("data");
  6. if(res){
  7. next();
  8. }else{
  9. next("/login")
  10. }
  11. }
  12. },

自定义路由高亮的类名

  1. const router = new VueRouter({
  2. mode: 'history',
  3. base: process.env.BASE_URL,
  4. routes,
  5. // 自定义路由高亮类名
  6. linkActiveClass: 'active',
  7. linkExactActiveClass: 'active1'
  8. })