Angular 如何在角10中急切地加载离子模式

Angular 如何在角10中急切地加载离子模式,angular,ionic-framework,ionic4,Angular,Ionic Framework,Ionic4,需要明确的是,我不认为这个问题与路由延迟加载有任何关系,因为这个问题存在于一个引导组件中,在该组件中,它无法按预期运行 我有一个离子模式,在没有检测到网络时从基本app.component触发。我需要确保在发送初始有效负载后,离子模式脚本可用;但是,当我加载应用程序,然后在“网络调试器”选项卡中关闭网络时,它是延迟加载。 vendor.js:41664 ChunkLoadError:加载区块20失败。 被引用的脚本在其网页注释中包含以下内容,并且似乎完全是一个代码。 /node\u module

需要明确的是,我不认为这个问题与路由延迟加载有任何关系,因为这个问题存在于一个引导组件中,在该组件中,它无法按预期运行

我有一个离子模式,在没有检测到网络时从基本app.component触发。我需要确保在发送初始有效负载后,离子模式脚本可用;但是,当我加载应用程序,然后在“网络调试器”选项卡中关闭网络时,它是延迟加载。
vendor.js:41664 ChunkLoadError:加载区块20失败。

被引用的脚本在其网页注释中包含以下内容,并且似乎完全是一个代码。
/node\u modules/@ionic/core/dist/esm/ionmodal.entry.js


如果我触发一个模式来显示然后隐藏,则区块将成功加载,并且当在网络调试器中触发时,以下网络错误模式将按预期工作。当我试图搜索有关“快速加载”的文章时,它总是与路由有关,而这不是我在这里寻找的内容。

结束此循环。在ionic v4.x中,这是不可能的,因为覆盖组件似乎是在运行时注册的。虽然
可以与JIT编译的模板一起使用,以便在需要时预加载脚本,但与AOT编译的模板一起使用时,它将失败。因此,目前的解决方案是在引导过程中或在IonicModule可用后尽早以编程方式呈现然后取消模式

  // Call this somewhere early where IonicModule has been imported, we are doing it in the app.component.ts constructor in our example
  async preloadModal() {
    let tempModal = await this.modalController.create({
      animated: false, // this should prevent it from being visible
      swipeToClose: false, // disable interaction to prevent unexpected behavior
      backdropDismiss: false, // disable interaction to prevent unexpected behavior
      showBackdrop: false, // minimize changes to UI
      keyboardClose: false, // minimize side-effects
      component: MyModalComponent, // Your custom modal component likely won't render, be sure to preload any related assets inside the index.html <head> tags
      componentProps: {
        // your component props, if needed
      }
    });
    await tempModal.present();
    await tempModal.dismiss();
  }
//在较早导入IonicModule的地方调用此函数,我们在示例中的app.component.ts构造函数中执行此操作
异步预加载模式(){
让tempModal=wait this.modalController.create({
动画:false,//这将阻止其可见
swipeToClose:false,//禁用交互以防止意外行为
BackDropDisclesh:false,//禁用交互以防止意外行为
ShowBackground:false,//最小化对UI的更改
keyboardClose:false,//最小化副作用
component:MyModalComponent,//您的自定义模式组件可能不会呈现,请确保在index.html标记中预加载任何相关资产
组件和支柱:{
//您的组件道具,如果需要的话
}
});
等待tempModal.present();
等待tempModal.discouse();
}

这是当前的解决方案,但不太理想。以下内容放在app.component.html中: