加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – 从选项卡转到根页面

发布时间:2020-12-17 07:19:39 所属栏目:安全 来源:网络整理
导读:我想知道如何在使用选项卡时返回appComponent中定义的rootPage. setRoot方法无法正常工作.在标签页中使用它时,不会清除导航堆栈.在“主页”上,可以看到后退按钮而不是导航切换,并显示选项卡的标题. By default,pages are cached and left in the DOM if they
我想知道如何在使用选项卡时返回appComponent中定义的rootPage. setRoot方法无法正常工作.在标签页中使用它时,不会清除导航堆栈.在“主页”上,可以看到后退按钮而不是导航切换,并显示选项卡的标题.

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模板中可用的主页标题.

就像你在 docs中看到的一样

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
,and NavController 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);
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读