相关疑难解决方法(0)

Ionic 4:"加载控制器"dismiss()在present()之前调用,它将保持微调器而不会被忽略

我使用"离子加载控制器"来显示一个微调器,直到检索到数据然后它调用"dismiss()"来解除它.它工作正常,但有时当应用程序已经拥有数据时,在"create()"和"present()"完成之前调用"dismiss()",这将保持微调器而不会消失...

我试图在"loadingController.present().then()"中调用数据,但这导致数据变慢...

这是一个错误吗?如何解决这个问题?

我的代码示例:

customer: any;

constructor(public loadingController: LoadingController, private customerService: CustomerService)

ngOnInit() {
  this.presentLoading().then(a => consloe.log('presented'));
  this.customerService.getCustomer('1')
  .subscribe(customer => {
    this.customer = customer;
    this.loadingController.dismiss().then(a => console.log('dismissed'));
  }
}

async presentLoading() {
  const loading = await this.loadingController.create({
    message: 'wait. . .',
    duration: 5000
  });
  return await loading.present();
}
Run Code Online (Sandbox Code Playgroud)

loading ionic-framework angular ionic4 angular6

16
推荐指数
3
解决办法
2万
查看次数

标签 统计

angular ×1

angular6 ×1

ionic-framework ×1

ionic4 ×1

loading ×1