离子 - 错误:未捕获(在承诺中):找不到removeView [英] Ionic - Error: Uncaught (in promise): removeView was not found

查看:854
本文介绍了离子 - 错误:未捕获(在承诺中):找不到removeView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Ionic应用程序工作正常但我没有做任何事情但突然间我收到此错误而我不知道原因。


错误:未捕获(承诺):找不到removeView



解决方案

当你想手动关闭离子加载时,你可能需要按照下面的例子。我在离子实验室测试过的工作正常。

  Ionic 3+ 

注意:
如果你手动调用this.loading.dismiss(),我不建议使用dismissOnPageChange,你可能会解雇相同的加载两次。



为什么以下解决方案有效?



我认为 this.loading.present()是一个异步方法,所以当 this.loading.present() this.loading.dismiss() c $ c>仍然在运行。



所以如果我们需要dis手动错过我们需要确保已经存在加载并有一个视图来解除它,我们应该在 present()之后使用其他方法。然后,如下面的代码。 / p>

但是我不确定为什么我们在旧框架版本(2.0.3)中没有这个问题。

 从'ionic-angular'导入{Loading,LoadingController}; 

导出类ApnSearchPage {
loading:正在加载;
构造函数(private loadingCtrl:LoadingController){}

ionViewDidLoad(){
this.createLoader();
}

createLoader(message:string =Please wait ...){//可选参数
this.loading = this.loadingCtrl.create({
内容:消息
});
}

public searchClick(){
this.createLoader();
this.loading.present()。then(()=> {
this.searchService.submitRequest(params,data)
.subscribe(response => {
this.loading.dismiss();
},错误=> {
this.loading.dismiss();
this.errorMessage =< any>错误
}) ;
});
}
}

参考链接,因此仅发布有用且有用的提示和代码。



我希望这有帮助!


My Ionic app was working fine and I haven't done anything to it but suddenly I am getting this error and I don't know why.

"Error: Uncaught (in promise): removeView was not found

解决方案

When you want to manually dismiss the Ionic loading you may need to follow the below example. Which is working fine I have tested in ionic labs.

Ionic 3+

Note: If you call this.loading.dismiss() manually, I don't recommend to use dismissOnPageChange, you are probably dismissing the same loading twice.

Why the below solution works?

I think this.loading.present() is an asynchronous method, so we can't call this.loading.dismiss() manually when this.loading.present() is still running.

So if we need to dismiss manually we need to make sure that loading is present already and have a view to dismiss it, we should use other method after present().then like the following code.

However I'm not sure why we didn't have this problem in the old framework version (2.0.3).

import { Loading, LoadingController } from 'ionic-angular';

export class ApnSearchPage {
   loading: Loading;
   constructor(private loadingCtrl: LoadingController) { }

   ionViewDidLoad() {
     this.createLoader();
   }

   createLoader(message: string = "Please wait...") { // Optional Parameter
     this.loading = this.loadingCtrl.create({
       content: message
     });
   }

   public searchClick() {
       this.createLoader();
       this.loading.present().then(() => {
       this.searchService.submitRequest(params, data)
            .subscribe(response => {
                this.loading.dismiss();
            }, error => {
              this.loading.dismiss();
              this.errorMessage = <any>error
            });
      });
   }
}

Reference Link,hence posted only useful and working tips and code.

I hope this helps!

这篇关于离子 - 错误:未捕获(在承诺中):找不到removeView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆