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



我正试图在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文件中,并且目前正在像swipper一样完美地在其他组件中工作。

问题是组件模块没有导入到实际调用Modal的组件中。虽然模态工作得很好,但即使没有导入到其他模块中,它的依赖项(如swipper(似乎也会失败。

最新更新