在Ionic 2中选择特定选项卡

编程入门 行业动态 更新时间:2024-10-28 10:28:58
本文介绍了在Ionic 2中选择特定选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用Ionic 2,我仍在努力完成大多数基本任务,比如在应用程序加载时选择一个标签。

I'm trying to use the Ionic 2 and I'm still struggling with most basic tasks, such as select a tab when the app is loading.

I我试图在 onPageLoaded 事件,但无济于事。

I've tried to inject the Tabs controller and call select on the onPageLoaded event, but to no avail.

有人可以帮忙吗?

推荐答案

要默认使用ionic 2中的选项卡,请更改selectedIndex属性:

To default to a tab in ionic 2 change the selectedIndex property:

<ion-tabs [selectedIndex]="1"> <ion-tab [root]="tab1Root" tabTitle="Home" tabIcon="rewind"></ion-tab> <!-- Index 0--> <ion-tab [root]="tab2Root" tabTitle="About" tabIcon="md-time"></ion-tab><!-- Index 1 (Selected)--> <ion-tab [root]="tab3Root" tabTitle="Contacts" tabIcon="fastforward"></ion-tab><!-- Index 2--> </ion-tabs>

页面加载时,关于选项卡将成为选中的选项卡。

The About tab will be the selected tab when the page loads.

更多推荐

在Ionic 2中选择特定选项卡

本文发布于:2023-11-07 04:06:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565530.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选项卡   Ionic

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!