gpt4 book ai didi

android - ionic 切换菜单不会关闭 Android 设备上的侧边菜单

转载 作者:行者123 更新时间:2023-12-04 21:28:54 24 4
gpt4 key购买 nike

我有一个 Ionic 4 项目,我正在使用侧面菜单。 There's a menu button that opens the menu, and in the menu is a list of menu-choices, when selected the menu-choice closes the side menu.这适用于浏览器,但不适用于设备。菜单将打开,但不会关闭。

我的侧边菜单在我的 app.component.html 中

<ion-app>
<ion-menu side="start" type="push" contentId="content1">
<ion-header>
<ion-toolbar color="primary">
<ion-title>Menu</ion-title>
</ion-toolbar>
</ion-header>
<ion-content class="light-grey">
<ion-list>
<ion-item (click)="toggleMenu()" [routerLink]="['/home']" routerLinkActive="active-link">Home</ion-item>
<ion-item (click)="toggleMenu()" [routerLink]="['/dashboard']" routerLinkActive="active-link">Dashboard</ion-item>
</ion-list>
</ion-content>
</ion-menu>
<ion-router-outlet id="content1" main></ion-router-outlet>
</ion-app>

这是主页的示例
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-menu-button autoHide="false" menuToggle></ion-menu-button>
</ion-buttons>
<ion-title>
Opportunity Forms
</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<ion-refresher slot="fixed" (ionRefresh)="ionRefresh($event)" >
<ion-refresher-content
pulling-icon="arrow-dropdown"
pulling-text="Pull to refresh"
refreshing-spinner="circles"
refreshing-text="Refreshing...">
</ion-refresher-content>
</ion-refresher>
<ion-card>
<ion-card-content>


</ion-card-content>
</ion-card>
</ion-content>

这是应用程序的屏幕截图

enter image description here

适用于 Chrome 版本 77.0.3865.90
经测试,在 Android 9 上菜单无法关闭

任何帮助表示赞赏,希望我提供了足够的信息。

-- 编辑(添加 app.component.ts) --
import { Component } from '@angular/core';

import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import {MenuController} from '@ionic/angular';
import { Router } from '@angular/router';

@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss']
})
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private menu: MenuController,
private route: Router
) {
this.initializeApp();
}

initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
toggleMenu() {
this.menu.toggle(); //Add this method to your button click function
}
}

最佳答案

请看这个。它讨论了这个问题:
https://github.com/ionic-team/ionic/issues/19354

他们建议将 @ionic/angular 更新到 4.11.2。这并不适用于所有人,但另一个对某人有用的建议解决方案是:

<ion-menu-toggle menu="first" autoHide="false">

关于android - ionic 切换菜单不会关闭 Android 设备上的侧边菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58343114/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com