vue搭建框架的爬坑之路

1.当用于路由输入的不匹配时,默认走404页面

router.beforeEach((to, from, next) => {
    if (to.matched.length === 0) { 
      from.name ? next({
        name: from.name
      }) : next('/error'); 
    } else {
      next(); //如果匹配到正确跳转
    }
  });

版权声明:本文为cccc0906原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。