angular5设置了默认路由,使用ng build打包后不生效

路由配置如下

const routes: Routes = [
  { path: '', redirectTo: '/a', pathMatch: 'full' },
  { path: 'a', component: AComponent },
  { path: 'b', component: BComponent },
  { path: 'c', component: CComponent }
];

使用ng server运行良好,但是使用ng build打包后再运行,配置的默认路由得内容就不出来了,要重新点击对应的链接后才出来

阅读 3.2k
2 个回答

try this:

const routes: Routes = [
{ path: '', redirectTo: 'a', pathMatch: 'full' },
{ path: 'a', component: AComponent },
{ path: 'b', component: BComponent },
{ path: 'c', component: CComponent }
];

解决了,是我的url写错了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进