You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ionic 6中使用ModalController集成DateTime选择器遇空弹窗问题

Ionic弹窗内容加载问题

通过popoverController或modalController创建的弹窗(Popovers/Modals)不会提前完成初始化,其内部内容也不会预渲染生成。

这就导致在由modalController渲染的组件中,使用以下代码无法实现预期功能,最终会出现空弹窗:

// 页面组件代码
async presentPopoverFilter(e: Event) {
  const popover = await this.modalController.create({
    component: PopoverFiltersComponent,
    componentProps: {
      profile: this.profile,
      filters: this.filters,
    },
  });

  await popover.present();
}
// 弹窗组件模板代码
<ion-datetime-button datetime="datetime"></ion-datetime-button>

<ion-popover [keepContentsMounted]="true">
  <ng-template>
    <ion-datetime id="datetime"></ion-datetime>
  </ng-template>
</ion-popover>

内容的提问来源于stack exchange,提问作者raphox

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 23:05:31