更新时间:2022-11-16 17:26:41
当您在mat-menu菜单上使用复选框(或任何响应点击的交互式元素)时,您不希望菜单在您关闭时关闭单击它,您需要通过使用MouseEvent.stopPropagation()
停止菜单来阻止菜单接收到click事件.尝试这样的事情:
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.