首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:断言错误: NgModule‘[对象模块]’不是'NgModuleType‘的子类型。[Expected=>空!=空<=Actual]

错误:断言错误: NgModule‘[对象模块]’不是'NgModuleType‘的子类型。[Expected=>空!=空<=Actual]
EN

Stack Overflow用户
提问于 2022-07-16 14:37:09
回答 1查看 729关注 0票数 -1

这是外壳程序的main.ts (端口: 5000),它正在调用微前端mfe1 (端口:3000)。

代码语言:javascript
复制
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的链接。

代码语言:javascript
复制
<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中调用它的应用路由

代码语言:javascript
复制
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'
 })

    },
];

每件事看起来都很好,模块成功

但是我得到了这个错误,组件没有显示

EN

回答 1

Stack Overflow用户

发布于 2022-07-17 10:34:54

shell\app.routes.ts )失踪.then((m) => m.FlightsModule)

代码语言:javascript
复制
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)
    },
];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73005064

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档