我正在尝试使用此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",
最佳答案
您正在使用错误的ng build
参数运行命令--base-href
。它需要以下格式的参数https://YOUR_GITHUB_USERNAME.github.io/PROJECT_NAME/
。
在这种情况下,github wiki信息似乎不准确。
关于javascript - Angular CLI Deploy to Github Pages问题:错误错误:未捕获( promise ):错误:无法匹配任何路由,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48436223/