gpt4 book ai didi

javascript - Angular CLI 部署到 Github 页面问题 : ERROR Error: Uncaught (in promise): Error: Cannot match any routes

转载 作者:行者123 更新时间:2023-12-01 02:29:21 25 4
gpt4 key购买 nike

我正在尝试使用此 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 部署到 Github 页面问题 : ERROR Error: Uncaught (in promise): Error: Cannot match any routes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48436223/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com