Ionic 3幻灯片无法使用自动播放

ANI*_*DAR 6 typescript ionic-framework ionic2 ionic3 angular

我正在使用离子3.

这是我的模板

 <ion-slides autoplay="5000" loop="true" speed="500" class="slides" pager="true">
      <ion-slide *ngFor="let Image of PImage">
         <img src="{{Image.URL}}" alt="Product Image">
      </ion-slide>
 </ion-slides>
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个错误

TypeError: Cannot read property 'hasAttribute' of undefined
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

请告诉我,

谢谢

seb*_*ras 16

当数据尚未准备就绪时,尝试创建幻灯片元素时似乎存在问题.要解决此问题,请*ngIf仅在数据准备就绪时使用an 创建幻灯片:

<ion-slides *ngIf="PImage && PImage.length"  autoplay="5000" loop="true" speed="500" class="slides" pager="true">
      <ion-slide *ngFor="let Image of PImage">
         <img src="{{Image.URL}}" alt="Product Image">
      </ion-slide>
 </ion-slides>
Run Code Online (Sandbox Code Playgroud)