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

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

问题描述

我的 Ionic 应用程序运行良好,但我没有对其进行任何操作,但突然出现此错误,我不知道为什么.

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.

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

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

推荐答案

当您想手动关闭 Ionic 加载时,您可能需要按照以下示例进行操作.我在离子实验室测试过,效果很好.

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+

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

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

为什么下面的解决方案有效?

我认为this.loading.present()是一个异步方法,所以我们不能在this的时候手动调用this.loading.dismiss().loading.present() 仍在运行.

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.

所以如果我们需要手动关闭,我们需要确保加载已经存在并有一个视图关闭它,我们应该在 present().then 之后使用其他方法,如下面的代码.

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.

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

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.

我希望这会有所帮助!

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

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