离子2侧菜单没有弹出

时间:2017-04-29 13:08:12

标签: html angular typescript ionic2

截至昨晚,我对Ionic完全陌生,我创建了一个空白项目,现在愚蠢地意识到我想在那里有一个侧面菜单。所以我已经按照几个在线教程添加了一个,但无论我尝试什么,我都可以在单击菜单切换图标按钮时显示菜单。

这是我添加的内容,试图让它发挥作用:

app.html

<ion-menu side="right" [content]="content">
    <ion-content>
        <ion-list>
            <button>Page 1</button>
            <button>Page 2</button>
        </ion-list>
    </ion-content>
</ion-menu>

<ion-nav #content [root]="rootPage" swipeBackEnabled="false"></ion-nav>

app.component.ts:

import { Component, ViewChild } from '@angular/core';
import { Platform, Nav } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { HomePage } from '../pages/home/home';
@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = HomePage;
  @ViewChild(Nav) nav: Nav;

  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();
    });
  }
}

家登录in.html:

<ion-header>
  <ion-navbar color='primary'>
    <button ion-button menu-toggle>
      <ion-icon name="menu"></ion-icon>
    </button>
  </ion-navbar>

</ion-header>


<ion-content padding>

</ion-content>

1 个答案:

答案 0 :(得分:2)

错误的属性。替换:

<button ion-button menu-toggle>

使用:

<button ion-button menuToggle>