Ang*_*bts 3 typescript angular ngx-swiper-wrapper swiper.js
我使用Swiper进行角度处理,并使用 Angular Swipper包装器。我正在尝试添加一个onclick滑动到下一张幻灯片的按钮。
但我不知道如何获取 Swiper 实例以及如何调用slidenext函数。我怎样才能做同样的事情?提前致谢。
Angular 12 / Swiper 6.8.1
.html
<swiper [slidesPerView]="4" [spaceBetween]="50">
<ng-template swiperSlide>
<app-product-item></app-product-item>
</ng-template>
</swiper>
<button (click)="swipeNext()">Prev</button>
<button (click)="swipePrev()">Next</button>
Run Code Online (Sandbox Code Playgroud)
.ts
@ViewChild(SwiperComponent) swiper: SwiperComponent;
swipePrev() {
this.swiper.swiperRef.slidePrev();
}
swipeNext() {
this.swiper.swiperRef.slideNext();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9861 次 |
| 最近记录: |