Ionic framework 停止加载页面
我使用的是Ionic 2,并希望通过类似于PHP die()的feather加载终止页面;作用 下面是我目前正在使用的方法Ionic framework 停止加载页面,ionic-framework,ionic2,Ionic Framework,Ionic2,我使用的是Ionic 2,并希望通过类似于PHP die()的feather加载终止页面;作用 下面是我目前正在使用的方法 fetch_data() { let loader = this.loadingCtrl.create({ content: 'Loading...' }); loader.present(); this.bank.types().subscribe( response => { this.linkBankTypes = respo
fetch_data() {
let loader = this.loadingCtrl.create({ content: 'Loading...' });
loader.present();
this.bank.types().subscribe( response => {
this.linkBankTypes = response.results;
loader.dismiss();
}, err => {
loader.dismiss();
loader = this.loadingCtrl.create({ content: 'No Internet connection. Make sure Wi-Fi or cellular data is turned on, then try again.' });
//Kill the page from here
});
}
PHP的die()函数停止页面的创建,并允许PHP运行环境向客户端浏览器返回严重错误消息
您可以通过抛出异常来导致Ionic崩溃,但这不是一种令人愉快的用户体验,因此不推荐这样做
相反,您可以导航到错误页面或显示指示错误的消息
NavController
的push
或pop
可用于导航到错误页或返回到上一页 你是说nav.pop?在loader.disease()
之后,是否需要再次显示加载?在我看来,一条简单的警报信息就足够了。另外,你认为“杀死页面”会发生什么。这里有几个选项-导航到任何其他页面/导航到主页/只需退出应用程序/转到internet设置?