Ionic framework 如何禁用背景菜单关闭-离子3
我很难找到这方面的文档 在Ionic中,菜单具有以下功能:如果单击背景,菜单将关闭。所以基本上只要点击菜单以外的任何地方,菜单就会消失。我想禁用此功能,以便用户可以与背景下的项目进行交互 我曾尝试禁用背景和菜单上的指针事件,但似乎仍会发生取消。有什么想法吗Ionic framework 如何禁用背景菜单关闭-离子3,ionic-framework,ionic3,Ionic Framework,Ionic3,我很难找到这方面的文档 在Ionic中,菜单具有以下功能:如果单击背景,菜单将关闭。所以基本上只要点击菜单以外的任何地方,菜单就会消失。我想禁用此功能,以便用户可以与背景下的项目进行交互 我曾尝试禁用背景和菜单上的指针事件,但似乎仍会发生取消。有什么想法吗 有趣的发现;菜单功能实际上看起来可能在离子内容上。这导致了一个问题: 我希望用户能够在不关闭菜单的情况下使用ion内容与内容交互 以下是示例代码,说明如何在ionic应用程序中执行此操作 import { Platform, Me
有趣的发现;菜单功能实际上看起来可能在离子内容上。这导致了一个问题:
- 我希望用户能够在不关闭菜单的情况下使用ion内容与内容交互
import { Platform, MenuController } from 'ionic-angular';
// ... Other code
constructor(menuCtrl: MenuController /* ... other code ...*/)
// ... Other code
let menu = menuCtrl.get();
menu.swipeEnable(false); // Disable drag to open/close
// Override default behaviour of closing the menu on
// content or backdrop click
menu['onBackdropClick'] = () => {
// No-op
};
menu.ionOpen.subscribe(() => {
// When the menu is open ...
// Remove Ionic's CSS rules for menu-content-open class that restricts
// mouse events on ion-nav
menu.getContentElement().classList.remove("menu-content-open");
// Reduce the size of the content pane so that it does not
// overflow off the screen
menu.getContentElement().style.width =
`calc(100% - ${menu.getMenuElement().clientWidth}px)`;
});
menu.ionClose.subscribe(() => {
// When the menu is closed ...
// Restore the size of the content pane
menu.getContentElement().style.width = '';
});
我做了一个stackblitz项目你可以看看。您可以从中为我查看,这有助于:
ion-menu {
pointer-events: none;
}
ion-menu > * {
pointer-events: all;
}