繁体   English   中英

Angular CLI Deploy to Github Pages问题:错误错误:未捕获(承诺):错误:无法匹配任何路由

[英]Angular CLI Deploy to Github Pages issue: ERROR Error: Uncaught (in promise): Error: Cannot match any routes

我正在尝试使用此https://github.com/angular/angular-cli/wiki/stories-github-pages将Angular SPA应用程序部署到github页面。

我运行此命令ng build --prod --output-path docs --base-href learningangular

learningangular是我的github存储库的名称。

这是路线

const appRoutes: Routes = [
  { path: "", redirectTo: "/abc", pathMatch: "full" },

  { path: "abc", component: OtherComponent },
  { path: "lazy", loadChildren: "./lazymodule/lazy.module#LazyModule" },

  {
    path: "example",
    loadChildren: "./ExampleModule/example.module#ExampleModule"
  },
  {
    path: "projects",
    component: ProjectsComponent,
    children: [
      {
        path: "",
        component: ErrorPage
      },
      {
        path: ":id",
        component: ProjectDetailsComponent
      }
    ]
  }
];

当我打开github.io/learningangular时,它重新路由到github.io/learningangular/learningangular/并给出错误

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'learningangular'
Error: Cannot match any routes. URL Segment: 'learningangular'

我究竟做错了什么?

我正在使用

 "@angular/core": "^5.0.0",
 "@angular/cli": "1.5.0",
 "@angular/compiler-cli": "^5.0.0",

您正在使用错误的--base-href参数运行ng build命令。 它需要以下格式的参数https://YOUR_GITHUB_USERNAME.github.io/PROJECT_NAME/

在这种情况下,github wiki信息似乎不准确。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM