单击图标无法导航到新页面

Unable to navigate to the new page on icon click

我正在尝试通过单击图标导航到新页面,组件如下所示

getTabDetails() {
  switch (this.tabContent) {
    case 'Shipment content':
      {
        this.router.navigateByUrl('/ProjectShipment/000634');
      }
  }
} 

我的路由组件如下所示

const appRoutes: Routes = [
  {
  path: 'dB',
  data: { title: 'Dashboard' },
  children: [
      {
          path: 'ProjectShipment/:reportProject',
          component: ProjectShipmentComponent,
          data: { title: 'Project Shipment' },
      }

单击图标时出现以下错误

Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'ProjectShipment/000634' Error: Cannot match any routes. URL Segment: 'ProjectShipment/000634'

但是当我尝试通过 URL 直接访问该页面时它有效

http://localhost:4200/dB/ProjectShipment/000634

我是不是遗漏了什么?

self.router.navigate(['./ProjectShipment/000634']);

你可以试试:

this.router.navigateByUrl(['ProjectShipment',000634], relativeTo:this.route);

其中

private route: ActivatedRoute

如果你在 /dB 路径