ionic-framework - 主页上的选项卡
问题描述
我试图在我的主页中创建选项卡,但是当我将主页作为选项卡中的选定索引时,页面没有加载,这是我的代码:
home.ts:
...
export class HomePage {
public isConnected: Boolean= true;
homeRoot = HomePage;
aRoot = SigninPage;
bRoot = SignupPage;
...
主页.html:
///SOME CONTENT
<ion-tabs selectedIndex="0" *ngIf="isConnected">
<ion-tab [root]="homeRoot" tabTitle="Home"></ion-tab>
<ion-tab [root]="aRoot" tabTitle="Home"></ion-tab>
<ion-tab [root]="bRoot" tabTitle="Home"></ion-tab>
</ion-tabs>
app.compenents.ts:
//IMPORTS
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = HomePage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
}
}
解决方案
创建一个新页面 TabsPage。
//制表符.ts
export class TabsPage{
public isConnected: Boolean= true;
homeRoot = HomePage;
aRoot = SigninPage;
bRoot = SignupPage;
//选项卡.html
<ion-tabs selectedIndex="0" *ngIf="isConnected">
<ion-tab [root]="homeRoot" tabTitle="Home"></ion-tab>
<ion-tab [root]="aRoot" tabTitle="Home"></ion-tab>
<ion-tab [root]="bRoot" tabTitle="Home"></ion-tab>
</ion-tabs>
//app.component.ts
//IMPORTS
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = TabsPage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen:
SplashScreen) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
}
}
推荐阅读
- html - 如何通过单击包含用户名的标签在 Angular 中打开一个新组件?
- html - net::ERR_NAME_NOT_RESOLVED,尝试通过 Chrome 或 Firefox 上的 HTML 链接获取谷歌字体时不允许错误的 URI 或跨站点访问
- python - 如何在不同时间调用python中的函数?
- java - JavaFX:从 FileChooser 获取图像并将其保存在一个字节 []
- wordpress - 为什么我的所有代码块都添加了水平滚动条?
- laravel - laravel 中的密码确认规则失败
- javascript - 有没有办法在 jsfiddle 上创建 API 并通过 JS fiddle 代码调用相同的 API?
- java - ConcurrentHashMap 相同sagement 上的读写器线程时的性能
- sql - ORDER BY 多个变量
- python - 我无法从 IDLE 或 cmd 运行 python