Ionic 2 - How do I get back to the start page of a

2019-05-29 08:08发布

问题:

My APP works with tabs, inside these tabs I have buttons that open other pages using push, when I click on tab 2, and click on a button, it opens the normal page, then I click on tab 1, and then click again in tab 2, but instead of showing the start page of tab 2, it already comes open with the page that I had clicked before ... How do I make it every time it clicks on a tab, it shows exactly the Page of that tab, and do not bring the page I had visited open? I tried using this.tabRef.select (0); Inside the tab.ts but it double-clicks on the first click of each tab, which causes a blink on the screen leaving it blank for a few seconds by calling it twice ... I tried this.navCtrl.setRoot (HomePage ) ;, but it takes the tabs off the screen, as it takes HomePage as the home page.

回答1:

Use this code in child pages of tab:

ionViewDidLeave(){
   this.navController.setRoot(/*your tab page*/);
}