本文介绍了Ionic2:'NavController'类型中不存在属性'present'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Ionic 2 rc4 。我正在按照的建议进行操作执行以下操作:

I am using Ionic 2 rc4. I am following the advise here and am trying to do the following:

import { NavController } from 'ionic-angular';
        ...
    this.nav.present(this.loading).then(() => {

然而,对我来说,看起来 NavController 没有现在的函数,因为我得到:

However, to me it looks like the NavController does not have a present function, because I get:

[ts] Property 'present' does not exist on type 'NavController'.
any


我是否正确,或者我是我做错了什么?他们如何获得这个幽灵功能?

Am I correct, or am I doing something wrong? How do they get to access this "phantom" function?

任何建议都赞赏。

更新

这是我的代码导致以下错误(在 this.loading.present()上。然后(()=> {):

Here is my code that results in the following error (on this.loading.present().then(() => {):

它首次显示加载。但是在 submit(),则会显示> alert ,它会出现此错误。

It presents loading the first time. but after the alert is presented if submit() is run again, it gets this error.

submit() {
            this.loading.present().then(() => {
                let alert = this.alertCtrl.create({
                    title: 'Verify Email',
                    subTitle: 'Please verify your email address before you log in.',
                    message: 'Check your Spam folder if you cannot find the email.',
                    buttons: [
                        {
                            text: 'Resend',
                            handler: data => {
                                firebaseUser.sendEmailVerification().then((data) => {
                                    this.doAlert('Verify Email', 'Verification Email Sent.').then((data) => {
                                        //navCtrl.setRoot(navCtrl.getActive());
                                    });
                                });
                            }
                        },
                        {
                            text: 'Okay',
                            handler: data => {
                                //navCtrl.setRoot(navCtrl.getActive());
                            }
                        }
                    ]
                });
                alert.present();
                this.loading.dismiss();
            });
}


推荐答案

看着这个

Looking at this changelog for Beta 11

他们从 Navcontroller 中删除​​了现在的函数。

They have removed present function from Navcontroller.

您需要重构代码并根据您的要求使用其他功能。
this.loading.present()

You need to refactor your code and use some other function based on your requirement.this.loading.present()

对于错误,请检查文档。

For the error, check the Loading controller docs.

this.loading = this.loadingCtrl.create({
   //loading properties
          });

之前在<$ c之前$ c> this.loading.present()

这篇关于Ionic2:'NavController'类型中不存在属性'present'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 23:52
查看更多