gpt4 book ai didi

css - mat-expansion-panel 添加下拉打开问题

转载 作者:太空宇宙 更新时间:2023-11-03 20:25:46 27 4
gpt4 key购买 nike

我添加了 Angular material mat-expansion-panel select option ,当我点击选择菜单时,mat-expansion-panel 自动打开,任何人都知道如何解决这个问题,

Stack blitz example

我的代码

component.html

<mat-accordion>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
<select class="form-control" id="exampleFormControlSelect1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</mat-panel-title>
<mat-panel-description>
Type your name and age
</mat-panel-description>
</mat-expansion-panel-header>

<mat-form-field>
<input matInput placeholder="First name">
</mat-form-field>

<mat-form-field>
<input matInput placeholder="Age">
</mat-form-field>
</mat-expansion-panel>
<mat-expansion-panel (opened)="panelOpenState = true"
(closed)="panelOpenState = false">
<mat-expansion-panel-header>
<mat-panel-title>
Self aware panel
</mat-panel-title>
<mat-panel-description>
Currently I am {{panelOpenState ? 'open' : 'closed'}}
</mat-panel-description>
</mat-expansion-panel-header>
<p>I'm visible because I am open</p>
</mat-expansion-panel>
</mat-accordion>

最佳答案

我没有遇到您描述的问题,但我明白您的意思。发生的情况是,当您单击选择时,您还单击了扩展面板。您可以通过阻止点击传递选择来防止此行为。

stopPropagation

在您的 HTML 中,将选择更改为:

<select class="form-control" id="exampleFormControlSelect1" (click)="$event.stopPropagation()">

关于css - mat-expansion-panel 添加下拉打开问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55448496/

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