我想手动移到下一张幻灯片,但出现错误。我试过这样:
<ion-slides #sliderRef pager="true" (ionSlideWillChange)="onSlideChangeStart($event)">
<ion-button (click)="slideNext()">Next</ion-button>
并在 ts 文件中:
import { Component, OnInit, ViewChildren, ElementRef } from '@angular/core';
import { IonSlides } from '@ionic/angular';
export class AppointmentPage implements OnInit {
@ViewChild('sliderRef', { static: true }) protected slides: ElementRef<IonSlides>;
constructor(){}
async slideNext(): Promise<void> {
await this.slides.nativeElement.slideNext();
}
...
}
通过调用 slideNext() 我有这个错误:
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'slideNext' of undefined