vue-router

"vue-router": "^4.0.12"

{

  path: '/:catchAll(.*)',
  name: 'home',
  component: () => import('@/views/Home/index.vue'),
},

代码如上

我使用重定向 只要路径不对应 我就跳转到首页 确实跳转到首页
但是导航栏里面的路由 没有变化 请问如何解决

阅读 1.7k
2 个回答

component: () => import('@/views/Home/index.vue')改成redirect: '/''/'要先在前面定义一下。

const routes = [
    {
        path: "/home",
        name: "Home",
        component: () => import("../views/Home.vue")
    },
    {
        path: "/about",
        name: "About",
        component: () => import("../views/About.vue")
    },

    {
        path: "/:catchAll(.*)",
        redirect: "/home"
    }
];
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题