本文介绍了在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 $ c上注入 Tabs 控制器并调用选择 $ c>事件,但无济于事。
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中选择特定选项卡
发布评论