【问题标题】:Ionic Capacitor Angular App is not showing loaderIonic Capacitor Angular App 未显示加载程序
【发布时间】:2022-08-11 16:15:56
【问题描述】:

我在加载服务文件中添加了一个 LoadingController。我正在调用 showLoader 方法,该方法是从我的组件中写入加载器服务文件中的。它运行成功,没有任何错误。但是在我的应用程序上,领导者没有出现。

不仅加载程序甚至 toast 消息也没有显示。而且也没有控制台错误。谁能帮我?

家庭组件:

import { Component, OnInit, ViewChild } from \'@angular/core\';
import { IonLoaderService } from \'../service/loader/ion-loader.service\';

@Component({
  selector: \'app-home\',
  templateUrl: \'./home.page.html\',
  styleUrls: [\'./home.page.scss\'],
})
export class HomePage implements OnInit {
constructor(private ionLoaderService: IonLoaderService) {
    this.showLoader();
  }

  showLoader() {
    this.ionLoaderService.showLoader();
  }
}

装载机服务

import { Injectable } from \'@angular/core\';
import { LoadingController } from \'@ionic/angular\';
@Injectable({
  providedIn: \'root\'
})
export class IonLoaderService {
  constructor(public loadingController: LoadingController) { }

  showLoader() {
    this.loadingController.create({
      message: \'Loading...\'
    }).then((response) => {
      response.present();
    });
  }
}
  • 更新您的装载机服务代码:async showLoader() { this.loading = await this.loadingController.create({ message: \'Please Wait\', showBackdrop: true }); await this.loading.present(); }

标签: angular ionic-framework ionic-native ionic6


【解决方案1】:

在你的装载机服务中试试这个:

  async presentLoading(m = 'Please Wait') {
    let loading = await this.loadingController.create({
      message: m,
      showBackdrop: true
    });
    await loading.present();
  }

  async stopLoading() {
    await this.loadingController.dismiss();
  }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-01
    • 2021-03-29
    • 1970-01-01
    • 2022-01-02
    • 2020-06-04
    • 2021-09-12
    • 1970-01-01
    相关资源
    最近更新 更多