仔细检查你的路由配置文件,我这里是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"