Angular 8-404组件会覆盖其他一些重定向路径

时间:2020-01-22 16:09:52

标签: angular angular2-routing angular-routing angular8

我正在研究2个有角度的应用程序,这些应用程序具有用于服务/组件或其他共享内容的外部公共目录。

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { AokPageNotFoundComponent } from './aok-page-not-found.component';
import { CmsPageGuard } from '@spartacus/storefront';

const routes: Routes = [
  {
    path: '**',
    component: AokPageNotFoundComponent,
    canActivate: [CmsPageGuard],
    data: { pageLabel: 'notFound', cxPath: 'pageNotFound' }
  }
];

@NgModule({
  imports: [CommonModule, RouterModule.forChild(routes)],
  declarations: [AokPageNotFoundComponent],
  exports: [AokPageNotFoundComponent]
})
export class AokPageNotFoundModule {}

上方是 PageNotFoundComponent ,可在两个应用程序的外部公用目录中找到。

import { RoutesConfig, RoutingConfig } from '@spartacus/core';

export const aokCpRoutesConfig: RoutesConfig = {
  home: { paths: [''] },
  logout: { paths: ['logout'] },
  courseoverview: {
    paths: ['courses/:courseCode'],
    paramsMapping: { courseCode: 'code' }
  },
  mydataoverview: {
    paths: ['mydataoverview']
  },
  billings: {
    paths: ['billings']
  },
  courses: {
    paths: ['courses']
  },
  dashboard: {
    paths: ['dashboard']
  },
  product: {
    paths: ['product/:productCode', 'product/:name/:productCode']
  },
  notFound: {
    paths: ['**', 'notFound']
  }
};

export const aokCpRoutingConfig: RoutingConfig = {
  routing: {
    routes: aokCpRoutesConfig
  }
};

这是其中一个应用程序的路由配置。我遇到的问题是 notFound 路径会覆盖以下内容:路径:['product /:productCode','product /:name /:productCode'] 例如,它不会覆盖诸如home或mydataoverview之类的简单路径。

有人对我应该如何解决此问题有一些建议吗?

0 个答案:

没有答案