【发布时间】:2021-04-02 20:40:03
【问题描述】:
我正在尝试在 ionic 应用程序中添加侧边菜单,但它没有出现,我正在附加所有文件,请帮助我!!
app.html 文件
<ion-menu [content]="mycontent">
<ion-header>
<ion-toolbar>
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<button ion-item (click)=o nLoad(ServicesMessPage)>
<ion-icon name="quote" item-left></ion-icon>
Mess
</button>
<button ion-item (click)=o nLoad(ServicesLaundryPage)>
<ion-icon name="quote" item-left></ion-icon>
Laundry
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav [root]="rootPage" #mycontent></ion-nav>
然后在 app.component.ts 我添加了所有必要的导入
app.component.ts 文件
import { Component, ViewChild } from '@angular/core';
import { Platform, NavController, MenuController } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { LoginPage } from '../pages/login/login';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage: any = LoginPage;
@ViewChild('mycontent') nav: NavController
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private menuCtrl: MenuController) {
platform.ready().then(() => {
statusBar.styleDefault();
splashScreen.hide();
});
}
onLoad(page: any) {
this.nav.setRoot(page);
this.menuCtrl.close();
}
}
在 ServicesPage html 中我包含了菜单
services.html
<ion-header>
<ion-navbar hideBackButton="true">
<ion-buttons start>
<button ion-button name="menu" menuToggle>
</button>
</ion-buttons>
<ion-title>Dashboard</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
</ion-content>
【问题讨论】:
-
(click)=o nLoad(ServicesLaundryPage)是打字错误吗? -
是的,这是拼写错误,但我仍然无法解决,它在另一个项目中工作正常
-
app.module.ts中有没有配置