禁用登录页面ionic 4上的菜单 [英] disable menu on login page ionic 4
问题描述
我第一次使用离子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);
}
}
我还尝试了在离子菜单中设置的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屋!