我使用img标签显示图像。我想在三秒钟后隐藏图像。请建议。
<ion-list>
<ion-item>
<img src="../assets/imgs/dots.gif" height="50px" width="50px" >
</ion-item>
</ion-list>
与setTimeout
*ngIf
<ion-list>
<ion-item *ngIf="showImage">
<img src="../assets/imgs/dots.gif" height="50px" width="50px" >
</ion-item>
</ion-list>
this.showImage = true;
setTimeout(()=>{
this.showImage = false;
},3000);
您只需要超时
imageShowing = true;
ngOnInit(){
let self = this;
setTimeout(function(){
self.imageShowing = false;
},3000);
}
在您的模板中
<ion-list>
<ion-item *ngIf="imageShowing">
<img src="../assets/imgs/dots.gif" height="50px" width="50px" >
</ion-item>
</ion-list>