我的问题是,我每次加载我的链接。例如: “https://www.example.com/”它将重定向到 “https://www.example.com/design-brief”,因为我在我的routing.ts中配置了它。 但是,当我使用链接“https://www.example.com/design-brief”并进入我的地址栏时,它将在控制台日志中显示错误。 “GET https://www.example.com/design-brief 404()”Angular Router获取404错误?
const APP_ROUTES: Routes = [
{ path: 'design-brief', component: DesignBriefComponent },
{ path: 'design-evaluation', component: DesignEvaluationComponent },
{ path: '', redirectTo: '/design-brief', pathMatch: 'full' },
{ path: "**",redirectTo:"/design-brief" } ];
这是我在我的routing.ts
It解决了我的问题。谢谢。 顺便说一句,有没有办法删除“#”?我的意思是,有没有办法解决它而不使用散列? – LordGrim
干净的方法是使用默认位置策略(所以不是哈希),并在Web服务器上进行一些配置,正如我所提到的。如果你确实使用HashLocationStrategy,那么#将留在:) –
如何配置它?我只是使用github(angular-cli-ghpages),以便我可以看到我的角色应用程序正在运行。这只是为了我的练习。但我想学习干净的方式或正确的方式。 – LordGrim