{
path: '/',
name: 'Home',
component: Layout,
redirect: '/core-view',
children: [
{
path: 'dashboard',
name: 'Dashboard',
component: () => import('@/views/dashboard.vue'),
},
],
},
在项目的路由中看到这样结构的一段代码。
direct和children同时出现。 但是当我尝试以 http://***/core-view/dashboard 去访问页面时,却跳到了404.
经过查阅之后vue-router官方文档,其对重命名的定义是:
也就是说,只有当url为 http://***/, vue-router会将其导向 http://***/core-view。
如果我想要以 http://***/core-view/dashboard 去访问 http://***/dashboard。则需要设置别名(alias)为'/core-view'。