且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

保持垫菜单打开角度

更新时间:2022-11-16 17:39:20

当您在 mat-menu 上使用复选框(或任何响应点击的交互式元素)时,并且您不希望菜单关闭时单击它,您需要通过使用 MouseEvent.stopPropagation() 停止菜单来防止菜单接收单击事件.尝试这样的事情:

When you use a checkbox (or any interactive element that responds to clicks) on a mat-menu, and you don't want the menu to close when you click it, you need to prevent the menu from receiving the click event by stopping it with MouseEvent.stopPropagation(). Try something like this:

<mat-checkbox (click)="$event.stopPropagation()">Check Me</mat-checkbox>

md-prevent-menu-close 功能来自用于 AngularJS 的旧 Angular Material - Angular Material (v6) 的最新版本"没有该功能.Angular Material(用于 AngularJS 的 v1.x)和 Angular Material2(用于 Angular 的 v2/5/6)不可互换.

The md-prevent-menu-close feature is from the old Angular Material for AngularJS - the 'latest version' of Angular Material (v6) doesn't have that feature. Angular Material (v1.x for AngularJS) and Angular Material2 (v2/5/6 for Angular) are not interchangeable.