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

发布于 2022-09-06 20:22:37 字数 312 浏览 20 评论 0

路由配置如下

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜`诱少女 2022-09-13 20:22:37

try this:

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

书间行客 2022-09-13 20:22:37

解决了,是我的url写错了

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文