【问题标题】:How to hide navbar in Ionic2如何在 Ionic2 中隐藏导航栏
【发布时间】:2017-09-11 11:37:17
【问题描述】:

我试图隐藏在 Ionic 2 中。我尝试了 <ion-navbar [hidden]="true">,但它不起作用。

谁能告诉我如何有条件地隐藏 ionic2 中的导航栏?

【问题讨论】:

    标签: angular typescript ionic2 ionic3


    【解决方案1】:

    您可以使用组件中的属性来隐藏/显示它

    <ion-navbar *ngIf="showNavbar">
    

    在你的组件代码中:

    import { Component, ViewChild } from '@angular/core';
    import { Content } from 'ionic-angular';
    
    @Component({
        selector: 'page-home',
        templateUrl: 'home.html'
    })
    export class HomePage {
    
      @ViewChild(Content) content: Content;
      public showNavbar: boolean;
    
      // ...
    
      public hideNavbar(): void {
        this.showNavbar = false;
    
        // You should resize the content to use the space left by the navbar
        this.content.resize();
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多