本文介绍了如何通过单击mat-expansion-panel-header来防止切换mat-expansion-panel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道mat-expansion-panel-headers是一个按钮.单击该按钮上的任意位置可切换扩展的打开/关闭.但我不想让用户单击标题上的任何位置并打开它.应该有一个小按钮.一按该按钮将打开/关闭扩展面板.我该怎么办?
I know mat-expansion-panel-headers is a button. clicking anywhere on that button toggles the expansion opens/closes. But I don't want to let users click anywhere on the header and open it. There should be a small button. One click on that button will open/close the expansion panel. How can I do that?
我已经尝试过了,但是没有用.
I have tried this, but it didn't work.
<mat-expansion-panel>
<mat-expansion-panel-header (click)="$event.preventDefault()">
<mat-panel-title>
MENU
</mat-panel-title>
</mat-expansion-panel-header>
推荐答案
您可以使用切换功能:
<mat-expansion-panel >
<mat-expansion-panel-header #panelH (click)="panelH._toggle()">
<mat-panel-title>
<i class="material-icons app-toolbar-menu" (click)="panelH._toggle()">menu </i>
</mat-panel-title>
<mat-panel-description>
</mat-panel-description>
</mat-expansion-panel-header>
请参见 stackblitz
这篇关于如何通过单击mat-expansion-panel-header来防止切换mat-expansion-panel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!