问题
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.
回答1:
If you only have a small set of pages that you are working with you can hook into the lifecycle hook for the view leave and trigger a pop to the root.
ionViewDidLeave() {
this.navCtrl.popToRoot();
}
回答2:
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);
来源:https://stackoverflow.com/questions/47857967/reset-a-stack-history-of-an-ionic-3-tab