By default,pages are cached and left in the DOM if they are navigated
away from but still in the navigation stack (the exiting page on a
push() for example). They are destroyed when removed from the
navigation stack (on pop() or setRoot()).
上面的陈述让我期望当我使用setRoot页面时从缓存中清除.当它在普通页面中使用但在选项卡中不可用时,这似乎是正确的.
在选项卡页面的类中,有一个函数可以在单击按钮时将根页面设置为home.
goToHome() { this.navCtrl.setRoot(HomePage); }
我怎样才能确保当我们返回到homePage时没有后退按钮,并且使用了组件的HTML模板中可用的主页标题.
Notice that each
<ion-tab>
binds to a[root]
property,just like
in the Navigation section above. That is because each
<ion-tab>
is really just a navigation controller. This means that each
tab has its own history stack,andNavController
instances injected
into children@Components
of each tab will be unique to each tab
因此,当以root身份设置页面时,您将使用该选项卡中的导航堆栈,而不是整个应用程序中的导航堆栈.这就是你需要通过以下方式获得主导航堆栈的原因:
constructor(private app: App,...) {...}
然后
yourMethod(): void { this.app.getRootNav().setRoot(YourPage); }