Angular URL 重写没有发生

Angular URL rewrite not happening

我在 localhost:4200 上托管了一个应用程序。单击编辑时获取列表后,页面导航正在发生,但 URL 未重写。

RouterModule.forRoot([
  { path: 'welcome', component: WelcomeComponent },
  { path: 'employee', component: EmployeeListComponent },
  { path: 'employee/add', component: EmployeeAddComponent },
  { path: 'employee/edit', component: EmployeeEditComponent },
  { path: 'customer', component: CustomerListComponent },
  { path: 'ap', component: PayablesComponent },
  { path: 'ar', component: ReceivablesComponent }
])

首页

编辑页面

两个页面的 URL 相同。

重写组件片段,

  <td>
    <a [routerLink]="['/employee/edit']"><i class="fa fa-pencil ky-teal-text"></i> </a> &nbsp; &nbsp;
    <a><i class="fa fa-close ky-red-text"></i> </a>
  </td>

添加相对路径看看,

  <a [routerLink]="['./employee/edit']"><i class="fa fa-pencil ky-teal-text"></i> </a> &nbsp; &nbsp;

组件中存在错误,因此 angular 没有重新路由就回退到之前成功的路由。修复组件中的错误后,重写进行得很好。谢谢和解决方案。