禁用登录页面 ionic 4 上的菜单 [英] disable menu on login page ionic 4
问题描述
我第一次使用ionic 4的beta版.我尝试禁用登录页面上的菜单,但遇到了一些问题.
I use the beta of ionic 4 for the first time. I try to disable the menu on a login page, but i have some trouble.
我已经使用 ionic-cli 和 sidemenu 模板创建了应用程序,然后生成了一个登录页面.
I've created the app with ionic-cli and the sidemenu template, then I generated a login page.
我从 app.component.html
I removed the <ion-split-pane>
from the app.component.html
我修改了 app-routing.module.ts 以重定向到我的登录屏幕.在我的登录文件中,我尝试放置一个 ngOnInit 事件来禁用此特定页面上的菜单
I modified the app-routing.module.ts to redirect to my login screen. In my login file, I tried to put an ngOnInit event to disable the menu on this specific page
import { Component, OnInit, AfterContentInit, AfterViewInit,OnDestroy } from '@angular/core';
import { MenuController } from '@ionic/angular';
@Component({
selector: 'app-login',
templateUrl: './login.page.html',
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit, AfterContentInit, AfterViewInit,OnDestroy {
constructor(public menuCtrl: MenuController) {}
ngOnInit() {
this.menuCtrl.enable(false);
this.menuCtrl.swipeEnable(false);
}
ngAfterContentInit() {
this.menuCtrl.enable(false);
this.menuCtrl.swipeEnable(false);
}
ngAfterViewInit() {
this.menuCtrl.enable(false);
this.menuCtrl.swipeEnable(false);
}
ngOnDestroy() {
this.menuCtrl.enable(true);
this.menuCtrl.swipeEnable(true);
}
}
我尝试在 ion-menu 中设置一个 id
I alto tried with an id set in ion-menu
<ion-menu swipeEnabled="true" #menu>
并使用
this.menuCtrl.enable(false, 'menu');
它不起作用,请有人帮助我.
It's not working, can some one help me please.
谢谢
推荐答案
Ionic 4.0.0 仍然支持 ionViewWillEnter
,使用以下代码:
Ionic 4.0.0 still supports ionViewWillEnter
, use below code:
ionViewWillEnter() {
this.menuCtrl.enable(false);
}
你可以找到完整的例子 此处.
You can find full example here.
这篇关于禁用登录页面 ionic 4 上的菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!