简体   繁体   English

离子2选项卡双击

[英]Ionic 2 tabs double tap

I have a dynamic tabs page in my Ionic2 app that looks like this: 我的Ionic2应用程序中有一个动态标签页,如下所示:

<ion-tabs #myTabs class="tabs-md" type="md" [tabsHighlight]="true" [selectedIndex]="mySelectedIndex">
  <ion-tab *ngFor="let tab of tabRoots" [root]="tab.page" [tabTitle]="tab.name" [tabIcon]="tab.icon"></ion-tab>
</ion-tabs>

When the user taps on a tab that is already selected and is therefore the root page already, the page will still reload. 当用户点击已经选择的选项卡,因此已经是根页面时,该页面仍将重新加载。 The issue is that I have a few custom animations that rerun when this happens. 问题是,发生这种情况时,我有一些自定义动画会重新运行。 So I want to disable the ability to navigate to your same root page. 因此,我想禁用导航到您的相同根页面的功能。

I've tried putting 我试过了

ionViewCanLeave() {
  return //viewchild of #myTabs and returns true if next page does not equal current page.
}

This worked in that it stopped the refresh of the current root page, but the app crashes when navigating to another page that isnt a root (a child page) because myTabs reference is undefined. 这样做的原因是,它停止了当前根页面的刷新,但是,由于未定义myTabs引用,因此导航到非根目录的另一个页面(子页面)时,应用程序崩溃。

Any advice on how to accomplish this? 有关如何完成此操作的任何建议? I would prefer to handle this from my tabs controller. 我希望从我的tabs控制器处理此问题。

Try : ionSelected() { // DO SOMETHING OR NOT } 尝试: ionSelected() { // DO SOMETHING OR NOT }

In your 'HomePage' for example. 以您的“首页”为例。

Links : https://forum.ionicframework.com/t/capturing-ion-tab-click-on-active-tab-event/56594/27 链接: https : //forum.ionicframework.com/t/capturing-ion-tab-click-on-active-tab-event/56594/27

I Hope I could help you. 希望可以为您服务。

This was caused by a bug in ionic which was fixed in version 3.0.1 这是由3.0.1版中修复的离子错误引起的

https://github.com/ionic-team/ionic/pull/11084 https://github.com/ionic-team/ionic/pull/11084

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM