如何在 Shell App 中访问微前端子应用路由 [Angular 13]
在我的远程应用程序中,我有以下路线:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论