离子标签卡在第一个显示的视图上 [英] Ionic tab stuck with first showed view

查看:84
本文介绍了离子标签卡在第一个显示的视图上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现离子选项卡有不希望有的行为。



基本上,我有一些选项卡,在第一个选项卡中,我有3个视图,一个视图通过tab1导致另一个视图可以访问tab1internal1视图,而这个可以访问同一选项卡中的tab1internal2视图,在那里没有问题。



但是我还有其他选项卡(我们称之为第二个选项卡选项卡),导致第一个选项卡中的tab1internal2正常工作,除了一个细节:



如果我还没有访问第一个选项卡,则访问tab1internal2视图从第二个选项卡到第一个选项卡,此tab1internal2视图保留为第一个选项卡的默认视图,触摸时应显示tab1Initial视图,但显示tab1internal2,好像选项卡显示的第一个视图就是该选项卡粘贴的视图



我有一个代码笔来显示此行为, https://codepen.io/Orion390/pen/ yajLKa , InternalPages选项卡是我正在谈论的第一个选项卡,关于选项卡使用该按钮访问InternalPages选项卡中的internal2视图,很容易复制我解释的行为。



顺便说一句,导航并不令我担心,我的问题只是当我触摸该选项卡时未显示所需的视图。



 < ion-tab title = InternalPages icon = ion-home href =#/标签/首页> 
< ion-nav-view name = home-tab>< / ion-nav-view>
< / ion-tab>

无论您如何浏览,都将该视图指定为默认视图?

解决方案

我有一个简单的解决方法,包括将ng-click = onTabSelected()放在选项卡中以及分配给选项卡的控制器中:

  $ scope.onTabSelected = function(){
$ state.go( tab.home);
}

这样,始终触摸选项卡会导致我想要的状态,而不是第一个显示的内容或其他内容,我希望它对某人有用,导致该问题的行为确实看起来像是离子错误。

I found an undesired behaviour with the ionic tabs.

Basically i have some tabs, in the first tab i have 3 views, one leading to another with the tab1Initial giving access to the tab1internal1 view, and this one giving access to the tab1internal2 view in the same tab, no problem there.

But i have other tab (let's call it second tab) that leads to tab1internal2 in the first tab, which works as expected, except for one detail:

If i haven't visited the first tab, and access tab1internal2 view from the second tab to the first tab, this tab1internal2 view remains as the default view of the first tab, which should show the tab1Initial view when touched but instead shows tab1internal2, as if the first view shown by a tab is the one that tab sticks with, and that is exactly my problem.

I have a codepen showing this behaviour, https://codepen.io/Orion390/pen/yajLKa , the InternalPages tab is the first tab i'm talking about, the About tab access the internal2 view in the InternalPages tab with that button, it's easy to replicate the behaviour i explained.

Btw, i am not worried by the navigation, my issue is only the tab not showing the view i need when i touch it.

Shouldn't this

<ion-tab title="InternalPages" icon="ion-home" href="#/tab/home">
    <ion-nav-view name="home-tab"></ion-nav-view>
  </ion-tab>

Assign that view as the default, no matter how you navigate?

解决方案

I have a simple workaround, consists in putting ng-click="onTabSelected()" in the tab, and in the controller assigned to the tabs:

$scope.onTabSelected = function () {
    $state.go("tab.home");
}

That way, always the tab is touched it will lead to the state i want, not the first shown or whatever, i hope it's useful for someone, the behaviour that gave the problem really looks like a bug in ionic.

这篇关于离子标签卡在第一个显示的视图上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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