ngx-perfect-scrollbar 可以用在有角度的材质元素上吗?

Abi*_*ong 5 angular-material perfect-scrollbar angular

我想在 mat-autocomplete 元素上添加完美的滚动条。是否可以在角度材质元素上添加 ngx 完美滚动条?

Tim*_*Tim 3

这就是我添加它的方式,但由于某种原因它在 Chrome 中有效,但在 Firefox 中却不行。如果我使用 Firefox 检查元素并展开覆盖 div,那么滚动条也会起作用,但只有在我展开该节点之后。如果您找到解决方案,请告诉我。

    <mat-form-field>
       <mat-chip-list #chipList>
       <mat-chip *ngFor="let item of itemsSelected"
              [selectable]="true"
              [removable]="true"
              (removed)="remove(item)">
         {{item}}
         <mat-icon matChipRemove>cancel</mat-icon>
       </mat-chip>
       <input placeholder="{{placeholder | translate}}"
           #itemInput
           [formControl]="itemCtrl"
           [matAutocomplete]="auto"
           [matChipInputFor]="chipList"
           [matChipInputAddOnBlur]="true">
       </mat-chip-list>
       <mat-autocomplete #auto="matAutocomplete" 
                         (optionSelected)="selected($event)" 
                         (opened)="matAutocompleteOpened()"
                         class="overflow-hidden">
          <perfect-scrollbar>
              <mat-option #matOption *ngFor="let item of filteredItems | async" [value]="item">
                 {{item}}
              </mat-option>
          </perfect-scrollbar>

       </mat-autocomplete>
    </mat-form-field>
Run Code Online (Sandbox Code Playgroud)

还有CSS

.mat-autocomplete-panel.overflow-hidden {
     overflow: hidden !important;
     position: relative !important;

    .ps__rail-y:hover {
         background-color: transparent !important;
    }
}
Run Code Online (Sandbox Code Playgroud)

@Component({
  ------
  encapsulation: ViewEncapsulation.None
})
Run Code Online (Sandbox Code Playgroud)