截至昨晚,我对 Ionic 完全陌生,我创建了一个空白项目,现在愚蠢地意识到我想要在那里有一个侧菜单。所以我已经按照几个在线教程添加了一个,但是无论我尝试什么,当我单击菜单切换图标按钮时,我都可以显示菜单。
这是我添加的内容以尝试使这项工作:
应用程序.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();
});
}
}
主页登录.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>
错误的属性。代替:
<button ion-button menu-toggle>
和:
<button ion-button menuToggle>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句