随身笔记
随身笔记

vue3 No match found for location with path "/"

仔细检查你的路由配置文件,我这里是name字段重名,也有可能是哪里单词写错也可能造成

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/login',
    name: 'Home', //改成别的名字就可以
    component: Login
  },
]

 

或者

 

添加一个静态路由,匹配任意路径指向404错误页面。这样能保证控制不会报错[Vue Router warn]: No match found for location with path “/***/index”

[
  ...
  {
     // hide: true,
     path: '/:pathMatch(.*)*',
     component: () => import('@/views/error-page/404'),
  }
]
测试路由版本vue-router": "^4.1.6"

 

没有标签
首页      前端资源      vue3 No match found for location with path "/"

随身笔记

vue3 No match found for location with path "/"
仔细检查你的路由配置文件,我这里是name字段重名,也有可能是哪里单词写错也可能造成 const routes = [ { path: '/', name: 'Home', component: Home }, { …
扫描二维码继续阅读
2021-11-28