从后面的历史记录中删除一个视图 - Ionic2 [英] Remove a view from the back history - Ionic2

查看:7
本文介绍了从后面的历史记录中删除一个视图 - Ionic2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何从 ionic2 中的后退历史记录(或导航堆栈)中删除视图吗?

Anyone knows how to remove a view from the back history (or navigation stack) in ionic2?

在 Ionic 1 中我解决了这个问题

In Ionic 1 I solved this with

this.$ionicHistory.nextViewOptions({
  disableAnimate: true, 
  disableBack: true
});

非常有用,例如,一旦成功登录,就可以从历史记录中完全删除我的应用程序的登录页面.

Would be really useful, for example, to fully remove the login page of my application from the history once a successfully login was performed.

在这种情况下,仅仅不显示后退按钮是不够的,因为 Android 终端在设备上拥有自己的物理后退按钮.

Just not showing the back button isn't enough in such case, since Android terminals got their own physical back button on the devices.

我尝试了,在我的登录函数返回一个成功的 promise 之后,在将下一页推入堆栈之前:

I tried, after my login function returned a successful promise and before pushing the next page in the stack:

this.navController.pop();

this.navController.remove(this.viewCtrl.index);

但不幸的是,两者都没有成功:(

but unfortunately both weren't successful :(

推荐答案

https://forum.ionicframework.com/t/solved-disable-back-in-ionic2/57457 找到了解决方案

this.nav.push(TabsPage).then(() => {
  const index = this.nav.getActive().index;
  this.nav.remove(0, index);
});

所以我想先push下一页很重要,等待promise answer然后删除当前视图

so I guess it's important to push the next page first, wait for the promise answer and then remove the current view

这篇关于从后面的历史记录中删除一个视图 - Ionic2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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