如何在 Ionic 4 中实现加载按钮?
How to implement a loading button in Ionic 4?
我想在我的 Ionic 4 应用程序中插入按钮,在表单中使用,一旦按下,在等待服务器响应期间,在操作期间在左侧显示 ring/circle/spinner。它是 Material 设计的一部分,但我没有在文档中找到任何内容。
我该如何实施?
我在评论中建议的解决方案如下所示:
<ion-button (click)="doRequest()">
<ion-label > <ion-spinner *ngIf="loading"></ion-spinner> Submit</ion-label>
</ion-button>
export class Component {
loading: boolean;
doRequest() {
this.loading = true;
this.service.makeRequest().subscribe(
res => {
this.loading = false;
// Do something else...
}
);
}
}
更新
按照@JanP 在评论中的建议更改为ion-spinner
我想在我的 Ionic 4 应用程序中插入按钮,在表单中使用,一旦按下,在等待服务器响应期间,在操作期间在左侧显示 ring/circle/spinner。它是 Material 设计的一部分,但我没有在文档中找到任何内容。 我该如何实施?
我在评论中建议的解决方案如下所示:
<ion-button (click)="doRequest()">
<ion-label > <ion-spinner *ngIf="loading"></ion-spinner> Submit</ion-label>
</ion-button>
export class Component {
loading: boolean;
doRequest() {
this.loading = true;
this.service.makeRequest().subscribe(
res => {
this.loading = false;
// Do something else...
}
);
}
}
更新
按照@JanP 在评论中的建议更改为ion-spinner