Ionic 2 - 如何返回给定选项卡的起始页面 [英] Ionic 2 - How do I get back to the start page of a given tab
问题描述
我的APP使用标签,在这些标签内我有按钮,使用 push
打开其他页面,当我点击标签2,然后点击按钮时,它会打开正常页面,然后我单击选项卡1,然后再次单击选项卡2,但它没有显示选项卡2的开始页面,它已经打开了我之前点击过的页面...我该如何制作它每次单击选项卡时,它都会显示该选项卡的页面,并且不会打开我访问过的页面?我尝试使用 this.tabRef.select(0);
在tab.ts内部,但双击每个标签的第一次点击,这会导致屏幕闪烁通过两次调用将它留空几秒钟...我尝试了 this.navCtrl.setRoot(HomePage);
,但是它会将标签从屏幕上取下来,因为它将HomePage作为主页。
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.
推荐答案
在标签的子页面中使用此代码:
Use this code in child pages of tab:
ionViewDidLeave(){
this.navController.setRoot(/*your tab page*/);
}
这篇关于Ionic 2 - 如何返回给定选项卡的起始页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!