为什么 Swiper 没有在离子模态上初始化?

Why Swiper is not being initialised on ionic modal?

我正在尝试在 Ionic Modal 上使用 Swiper Angular,但未初始化滑动器。当应用程序运行时,它不会在控制台中显示任何错误,但是当检查代码时,我得到这个:

<swiper _ngcontent-kch-c220="">
  <!--container-->
  <!--container-->
  <!--container-->
</swiper>

这就是我实现刷卡器的方式:

<swiper
  #swiper
  [slidesPerView]="3"
  [spaceBetween]="50"
  (swiper)="onSwiper($event)"
  (slideChange)="onSlideChange()">
  <ng-template swiperSlide>Slide 1</ng-template>
  <ng-template swiperSlide>Slide 2</ng-template>
  <ng-template swiperSlide>Slide 3</ng-template>
</swiper>

组件的模块:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SetupConfirmComponent } from '@shared/components/setup-confirm/setup-confirm.component';
import { IonicModule } from '@ionic/angular';
import { SwiperModule } from 'swiper/angular';

@NgModule({
  declarations: [SetupConfirmComponent],
  imports: [CommonModule, IonicModule, SwiperModule],
  exports: [SetupConfirmComponent],
})
export class SetupConfirmModule {}

此外,CSS 已导入到主 CSS 文件中,并且当前可以正常工作,因为滑动器在其他组件中可以完美运行。

这个问题是组件模块没有导入到实际调用模态的组件中。虽然模态完美运行,但即使未导入到其他模块,它的依赖项(如 swiper)似乎也会失败。