问题描述
我有两张地图。每张地图都在自己的视图中。我正在使用制表符从视图跳转到视图。但是,当我使用这种导航方法时,没有设置根,并且一旦访问了页面,页面就不会被推送或弹出或设置。这是我正在使用的谷歌地图的问题。当我在菜单区域中使用带有set root的常规菜单时,似乎不会发生此功能。请帮忙。谢谢。
tabs.html
< ion-tabs>
< ion-tab [root] =tab1Root[tabTitle] =tab1Title>< / ion-tab>
< ion-tab [root] =tab2Root[tabTitle] =tab2Title>< / ion-tab>
< / ion-tabs>
tabs.ts
export class TabsPage {
$ p $请输入以下示例
tab1Root:any = Tab1Root;
tab2Root:any = Tab2Root;
tab1Title =title1;
tab2Title =title2;
构造函数(public navCtrl:NavController){
}
}
tabs.html strong>
< ion-tabs [selectedIndex] =mySelectedIndex>
< ion-tab [root] =tab1Root[tabTitle] =tab1Title>< / ion-tab>
< ion-tab [root] =tab2Root[tabTitle] =tab2Title>< / ion-tab>
< / ion-tabs>
tabs.ts
从'ionic-angular'导入{NavParams};
导出类TabsPage {
tab1Root:any = Tab1Root;
tab2Root:any = Tab2Root;
tab1Title =title1;
tab2Title =title2;
构造函数(navParams:NavParams){
this.mySelectedIndex = navParams.data.tabIndex || 0;
}
}
在menu.ts中添加以下代码(app.ts)导航文件
openPage(page){
let params = {};
if(page.index){
params = {tabIndex:page.index};
}
}
我希望它适合你。
I have two maps. Each map is on its own view. I am using tabs to jump from view to view. However, when I use this method of navigation, the root is not being set and the page is not being pushed or popped or set once it has been visited. This is an issue with the google maps I am using. This functionality doesn't seem to take place when I am using a regular menu with set root in the menu area. Please Help. Thanks.
tabs.html
<ion-tabs> <ion-tab [root]="tab1Root" [tabTitle]="tab1Title"></ion-tab> <ion-tab [root]="tab2Root" [tabTitle]="tab2Title"></ion-tab> </ion-tabs>
tabs.ts
export class TabsPage { tab1Root: any = Tab1Root; tab2Root: any = Tab2Root; tab1Title = "title1"; tab2Title = "title2"; constructor(public navCtrl: NavController) { } }
解决方案Please use following example
tabs.html
<ion-tabs [selectedIndex]="mySelectedIndex"> <ion-tab [root]="tab1Root" [tabTitle]="tab1Title"></ion-tab> <ion-tab [root]="tab2Root" [tabTitle]="tab2Title"></ion-tab> </ion-tabs>
tabs.ts
import { NavParams } from 'ionic-angular'; export class TabsPage { tab1Root: any = Tab1Root; tab2Root: any = Tab2Root; tab1Title = "title1"; tab2Title = "title2"; constructor(navParams: NavParams) { this.mySelectedIndex = navParams.data.tabIndex || 0; } }
Add following code in menu.ts(app.ts) file for navigation
openPage(page) { let params = {}; if (page.index) { params = { tabIndex: page.index }; } }
I hope its work for you.
这篇关于setRoot for Ionic 2+中的Tab页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!