如何解决为什么 Ionic 3 离子加载器抛出 removeView 错误/在关闭/呈现检查到位时不显示
我正在使用离子加载组件,该组件在第一次访问视图以及显示和关闭加载器时工作正常。
import { AlertController,LoadingController } from 'ionic-angular';
constructor(
public zone: NgZone,public loadingCtrl: LoadingController,public alertCtrl: AlertController,private storage: Storage,public navCtrl: NavController
) {
this.loading = this.loadingCtrl.create();
}
tryGeolocation() {
this.loading.present();
//misc code
this.markers.push(marker);
this.map.setCenter(pos);
//if(this.loading){
this.loading.dismiss();
}
但是,当我导航回视图并再次显示加载程序时,我收到一个错误:
错误:未捕获(承诺):未找到 removeView
我尝试遵循建议 here 并引入检查以查看加载器是否已被解除,但现在加载器从未出现:
if (this.loading == null){
console.log("Map.ts: Presenting loader.");
this.loading.present();
}
if (this.loading != null){
console.log("Map.ts: Dismissing loader.");
this.loading.dismiss();
}
我正在使用离子 3.9.9,角度 5.2.11 任何输入表示赞赏。
解决方法
似乎根据上下文分配了不同的解决方案,对我来说,解决方案是将加载器创建调用从模块构造函数移动到调用存在和解除的方法:
tryGeolocation() {...
this.loading = this.loadingCtrl.create();
this.loading.present();
//some code
this.loading.dismiss();
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。