重置Ionic 3选项卡的堆栈历史记录 [英] Reset a stack history of an Ionic 3 tab

查看:381
本文介绍了重置Ionic 3选项卡的堆栈历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在玩标签时,我举了一个带有2个标签的离子应用程序示例(tab1和tab2)。使用tab1,我可以转到tab1-> page1-> page2(通过导航)。
但关键的情况是当我点击我当前的标签(tab1)到tab2然后回来点击tab1我在我面前得到page2但我需要重置堆栈并获得tab1页面。

When playing with tabs, I take an example of an ionic app with 2 tabs (tab1 and tab2). With tab1 I can go to tab1->page1->page2 (through the navigation). But the crucial scenario for is that when I click away from my current tab(tab1) to tab2 and come back to click on tab1 I get page2 in front of me but I need to get the stack reset and get tab1 page.

推荐答案

我到现在为止找到的答案,特别是页数很少,就是实现这个钩子:

The answer I find till now, especially with few number of pages is to implement that hook:

 ionViewDidLeave(){
    this.navCtrl.popToRoot();
  }

其他一些解决方案对我有用:

Some other solution also worked for me:

this.navCtrl.setRoot(MyPage);

这篇关于重置Ionic 3选项卡的堆栈历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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