如何在 Shell App 中访问微前端子应用路由 [Angular 13]

发布于 2025-01-18 21:49:43 字数 1112 浏览 4 评论 0原文

在我的远程应用程序中,我有以下路线:

const routes: Routes = [
  {
    path: '',
    component: RNDFirstComponent,
    pathMatch: 'full',
  },
  {
    path: 'rnd2',
    component: RNDSecondComponent,
    pathMatch: 'full',
  },
  {
    path: 'rnd3',
    component: RNDThreeComponent,
    pathMatch: 'full',
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class RNDSectionRoutingModule { }

在家庭组件中,我有3个链接的上述路线链接,并且它适用于独立应用程序。在将远程应用集成到Shell应用程序中后,远程链接的错误下方单击:

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'rnd2'

下面是我的远程和Shell应用程序WebPack设置。

Remote
// For remotes (please adjust)
        name: "rdapp",
        filename: "remoteEntry.js",
        exposes: {
            './RNDSectionModule': './/src/app/rnd/rnd.module.ts',
            RNDFirstComponent: './/src/app/rnd/rndfirst.component.ts',
            RNDSecondComponent: './/src/app/rnd/rndsecond.component.ts',
            RNDThreeComponent: './/src/app/rnd/rndthree.component.ts',
        },   

In my remote app I have below routes :

const routes: Routes = [
  {
    path: '',
    component: RNDFirstComponent,
    pathMatch: 'full',
  },
  {
    path: 'rnd2',
    component: RNDSecondComponent,
    pathMatch: 'full',
  },
  {
    path: 'rnd3',
    component: RNDThreeComponent,
    pathMatch: 'full',
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class RNDSectionRoutingModule { }

And in Home component I have 3 links for above route and it is working fine for standalone app. After integrating remote app into Shell app getting below error for remote link click :

ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'rnd2'

Below is my remote and shell app webpack settings.

Remote
// For remotes (please adjust)
        name: "rdapp",
        filename: "remoteEntry.js",
        exposes: {
            './RNDSectionModule': './/src/app/rnd/rnd.module.ts',
            RNDFirstComponent: './/src/app/rnd/rndfirst.component.ts',
            RNDSecondComponent: './/src/app/rnd/rndsecond.component.ts',
            RNDThreeComponent: './/src/app/rnd/rndthree.component.ts',
        },   

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文