Ionic 6装载控制器存在不是功能错误

v7pvogib  于 2022-12-08  发布在  Ionic
关注(0)|答案(1)|浏览(114)

我最近更新了我的离子4到离子6。突然我的加载不再工作了,控制台抛出了一个“加载。目前不是一个函数”的错误。这是我的个人加载,我正在使用加载控制器组件。

import { Injectable, OnInit } from '@angular/core';
import { LoadingController } from '@ionic/angular';
import { MessageUtil } from './message.util';

export function easyMarineLoadingCreator(loadingController: LoadingController, messageUtil: MessageUtil) {
    // tslint:disable-next-line: no-use-before-declare
    return new EasyMarineLoading(loadingController, messageUtil);
}

@Injectable()
export class EasyMarineLoading {

    loader: HTMLIonLoadingElement = null;
    constructor(
        private loadingController: LoadingController,
        private messageUtil: MessageUtil
    ) {
    }

    async create() {
        const options: {} = {
            message: this.messageUtil.translateKey('LOADING'),
            translucent: true
        };
        this.loader = await this.loadingController.create(options);
    }

    public async present() {
        if (!this.loader) {
            await this.create();
        }
        this.loader.present();
    }

    public async dismiss() {
        if (this.loader) {
            this.loader.dismiss();
            this.loader = null;
        }
    }

    public getLoader(): HTMLIonLoadingElement {
        if (this.loader) {
            return this.loader;
        }
        this.create();
        return undefined;
    }

    public setLoader(loader: HTMLIonLoadingElement) {
        this.loader = loader;
    }
}

每当我示例化这个服务并运行.present()函数时,错误就会发生...有什么想法吗?

ve7v8dk2

ve7v8dk21#

我遇到了同样的问题,并尝试了这个:

this.loadingController.create({
        message: 'Loading...'
    }).then((response) => {
        response.present();
    });

从这里开始https://www.positronx.io/ionic-loading-controller-tutorial-with-ion-loading-example/

相关问题