简体   繁体   English

Mat-Select 仅在单击底线时打开

[英]Mat-Select only opening when clicked on bottom line

I implemented Mat-Select from Angular material (TS) and noticed interesting behavior.我从 Angular 材料 (TS) 实现了 Mat-Select,并注意到了有趣的行为。 Dropdown not opening until clicked on bottom line of mat-select and I know when I worked before with Mat-select field it was opening when I clicked anywhere on field.在单击 mat-select 的底线之前,下拉菜单不会打开,我知道当我之前使用 Mat-select 字段时,当我单击字段上的任何位置时它会打开。 What is the problem?问题是什么?

  <mat-form-field>
    <mat-label>Toppings</mat-label>
    <mat-select [formControl]="toppings" multiple>
      <mat-option *ngFor="let topping of toppingList" [value]="topping">{{
        topping
      }}</mat-option>
    </mat-select>
  </mat-form-field>

行为

From documentation https://material.angular.io/components/select/overview从文档https://material.angular.io/components/select/overview


might be a cache issues or the dynamic data must be loading late (adding a condition might help)可能是缓存问题或动态数据必须延迟加载(添加条件可能会有所帮助)

Stackblits- Stackblits-
https://stackblitz.com/angular/rdlobdgvqok?file=src%2Fapp%2Fselect-overview-example.ts https://stackblitz.com/angular/rdlobdgvqok?file=src%2Fapp%2Fselect-overview-example.ts

<h4>Basic native select</h4>
<mat-form-field>
  <mat-label>Cars</mat-label>
  <select matNativeControl required>
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </select>
</mat-form-field>

this will surely solve your issues这肯定会解决你的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM