在Ionic 2中选择特定选项卡 [英] Select a specific tab in Ionic 2

查看:88
本文介绍了在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 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中选择特定选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆