如何使用if else语句来回切换图像? [英] How can i implement a switching image back and forth using if else statement?
本文介绍了如何使用if else语句来回切换图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我不会使用if else语句来回切换建筑布局图像到建筑设计图像,但是我不知道如何实现它.我是这种类型的脚本的新手,有人愿意分享答案吗?
Hi everyone i wan't to switch building layout image to building design image back and forth using if else statement but i don't know how to implement it. I'am new in this type script, anybody would love to share an answer?
感谢您的高级答案
推荐答案
以下是通过操作切换图像的示例组件:
here is an example-component to switch a image by a action:
组件的HTML:
<ion-list>
<ion-item *ngIf="showImage1">
<img src="../assets/imgs/dots.gif" height="50px" width="50px" >
</ion-item>
<ion-item *ngIf="showImage2">
<img src="../assets/imgs/dots.gif" height="50px" width="50px" >
</ion-item>
</ion-list>
<ion-button (click)="DoHideImage1()" expand="block" color="light">
Image2
</ion-button>
<ion-button (click)="DoHideImage2()" expand="block" color="light">
Image1
</ion-button>
Typescript of component:
________________________________________
public showImage1: boolean;
public showImage2: boolean;
constructor() {
this.showImage1 = true;
this.showImage2 = false;
}
DoHideImage1(){
this.showImage1 = false;
this.showImage2 = true;
};
DoHideImage2(){
this.showImage1 = true;
this.showImage2 = false;
};
* ngIf隐藏在条件中!根据您的需要修改示例!
The *ngIf hides on condition ! Modify the example for your needs!
这篇关于如何使用if else语句来回切换图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文