我创建了 Ionic-Angular PWA。我已将 ionic 版本更新为 5.7.0。根据这个新的更新,我正在尝试用 swiper-slide 替换 ion-slides,因为 ion-slides 已被弃用。
swiper:6.8.4
离子:5.7.0
角度:12.0.2
在我的代码中
app.module.ts
import { SwiperModule } from 'swiper/angular';
@NgModule({
imports: [SwiperModule],
})
组件.ts
import SwiperCore, { Navigation, Pagination } from 'swiper';
import { IonicSwiper } from '@ionic/angular';
SwiperCore.use([IonicSwiper, Navigation, Pagination]);
export class GenesisPage implements OnInit {
slideOpts = {
initialSlide: 0,
speed: 400,
loop: true,
autoplay: {
disableOnInteraction: false
},
pagination: {
el: '.swiper-pagination',
clickable: true,
renderBullet(index, className) {
const newClass = `${className} myCustomPager`;
return `<span class="${newClass}"></span>`;
}
}
};
组件.html
<swiper [pagination]="slideOpts.pagination" [initialSlide]="slideOpts.initialSlide"
[speed]="slideOpts.speed" [loop]="slideOpts.loop" [autoplay]="slideOpts.autoplay">
<swiper-slide>
<div class="image-wrapper">
<img loading="lazy" *ngIf="!webp" width="640" height="360"
src="assets/images/genesis/launch-slide-1-new.png" class="first" alt="launch slide"
useImg />
<img loading="lazy" *ngIf="webp" width="640" height="360"
src="assets/images/genesis/launch-slide-1-new.webp" class="first" alt="launch slide"
useImg />
</div>
<div class="slide-content-wrap">
<h2>DISCOVER</h2>
<p>& EXPLORE</p>
</div>
</swiper-slide>
</swiper>
谁能帮我解决这个问题。提前致谢。
