这是外壳程序的main.ts (端口: 5000),它正在调用微前端mfe1 (端口:3000)。
import { loadRemoteEntry } from '@angular-architects/module-federation';
Promise.all([
loadRemoteEntry('http://localhost:3000/remoteEntry.js', 'mfe1')
])
.catch(err => console.error('Error loading remote entries', err))
.then(() => import('./bootstrap'))
.catch(err => console.error(err));这是调用mfe1模块app.module.html的链接。
<ul>
<li><img src="../assets/angular.png" width="50"></li>
<li><a routerLink="/">Home</a></li>
<li><a routerLink="/flights/flights-search">Flights</a></li>
</ul>
<router-outlet></router-outlet>我在导入( imports RouterModule.forRoot,APP_ROUTES)中的RouterModule.forRoot中调用它的应用路由
import { Routes } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { loadRemoteModule } from '@angular-architects/module-federation';
export const APP_ROUTES: Routes = [
{
path: '',
component: HomeComponent,
pathMatch: 'full'
},
{
path: 'flights',
loadChildren: () =>
loadRemoteModule({
// We don't need this anymore b/c its loaded upfront now
// remoteEntry: 'http://localhost:3000/remoteEntry.js',
//type: 'manifest',
remoteName: 'mfe1',
exposedModule: './Module'
})
},
];每件事看起来都很好,模块成功
发布于 2022-07-17 10:34:54
shell\app.routes.ts )失踪.then((m) => m.FlightsModule)
import { Routes } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { loadRemoteModule } from '@angular-architects/module-federation';
export const APP_ROUTES: Routes = [
{
path: '',
component: HomeComponent,
pathMatch: 'full'
},
{
path: 'flights',
loadChildren: () =>
loadRemoteModule({
// We don't need this anymore b/c its loaded upfront now
// remoteEntry: 'http://localhost:3000/remoteEntry.js',
//type: 'manifest',
//type: 'module',
//remoteEntry: 'http://localhost:3000/remoteEntry.js',
remoteName: 'mfe1',
exposedModule: './Module'
}).then((m) => m.FlightsModule)
//import('mfe1/Module').then(m => m.FlightsModule)
},
];https://stackoverflow.com/questions/73005064
复制相似问题