angular7 - 如何在 http 获取请求和响应中使用离子加载?
问题描述
我正在创建 Ionic 4 Angular 应用程序,并且正在使用 http 获取和响应。现在我想在请求和响应时进行离子加载。下面我粘贴这个解决方案链接,它在 ionic 3 中可用,但我想要在 ionic 4 中?
解决方案
导入加载控制器
import { LoadingController } from '@ionic/angular';
在构造函数中创建一个对象
constructor(
private loadingController: LoadingController
) {}
尝试如下。
async presentLoading() {
const loading = await this.loadingController.create({
message: 'Please wait...',
translucent: true,
});
return await loading.present();
}
homeData() {
this.presentLoading();
this.dataService.getData().subscribe(response => {
console.log(response);
this.loadingController.dismiss();
});
}
见官方文档ion-loading
推荐阅读
- javascript - 为什么将base64转换为PNG图像会导致黑色图像?
- performance - Quesdb 性能是否随着新 geohash 类型的实施而改变?
- python - 如何在聚类算法中使用距离矩阵?
- python - 如何在python中处理字符串字典
- r - 数据框中的所有 NA 列值都用 R 中的中值填充
- pdf - Adobe Sign API - 将签名字段放入 PDF 表单
- javascript - nightwatch 中的 .assert.containsText() 无法正常工作
- azure - Azure 应用服务部署不提供正确的文件
- mysql - 使用 Go 安全地执行数据库迁移
- python - 如何使用来自另一个数据帧的列和索引号更新熊猫数据帧?