Angular 浏览器刷新时,线段的角度布线失败

Angular 浏览器刷新时,线段的角度布线失败,angular,routing,Angular,Routing,我有一个角度路由问题,特别是路由。 路由正在使多个段失败 {path:'class',component:ClassComponent} {path:'class/student',component:StudentComponent} 本地主机:/3000/类 本地主机:/300/班/学生 第一个有效,但当浏览器刷新或我手动写入URL时,第二个失败 localhost/300/class/student 应该是 localhost:3000/class/student 我不清楚您的问题,

我有一个角度路由问题,特别是路由。 路由正在使多个段失败

{path:'class',component:ClassComponent}
{path:'class/student',component:StudentComponent}
  • 本地主机:/3000/类
  • 本地主机:/300/班/学生
  • 第一个有效,但当浏览器刷新或我手动写入URL时,第二个失败

    localhost/300/class/student
    
    应该是

    localhost:3000/class/student
    

    我不清楚您的问题,我认为您无法导航到
    班级/学生
    。如果是这样的话,

    应该是这样的

    {path:'class/student',component:StudentComponent}
    {path:'class',component:ClassComponent}
    
    或者你可以这样做

    {path:'class', component:ClassComponent}
    {path:'class/student', component:StudentComponent, pathMatch: 'full'}
    

    在你的例子中,url中的“类”是满意的,因此它不会改变。

    谢谢Jain,这是在写问题时的一个输入错误,但实际上是我在代码中的更正未能加载资源:服务器响应状态为404(未找到)。我建议一件事,在路由器配置中启用
    routerTracing
    ,您将了解出了什么问题。有关同一问题的更多信息,请参阅您的项目是否已部署?您必须在服务器配置中将回退url添加到index.html。