Angular 7,Material 2,页面滚动到打开对话框的顶部
Angular7, Material2, page scroll to top on open dialog
我有一个按钮可以打开 material 对话框。在打开的对话框中,后台页面滚动到顶部。关闭对话框时,页面会滚动回原来的位置。
谁可以阻止此滚动?
const dialogRef = this.dialog.open(dialogComponent, {
panelClass: config.panelClass,
width: 1100px,
height: 800px,
closeOnNavigation: true,
maxHeight: '95%',
maxWidth: '95%',
data: {
someData...
},
});
我的html
<div class="dialog dialog__content">
<div>
<div *ngIf="title" class="dialog__header">
<h1 mat-dialog-title>{{title | translate}}</h1>
</div>
<div class="dialog__closing">
<button matDialogClose>
<i class="fal fa-times-circle"></i>
</button>
</div>
</div>
<mat-dialog-content>
...some content...
</mat-dialog-content>
<mat-dialog-actions *ngIf="buttons && buttons.length > 0">
<div class="buttons">
<button>...</button>
</div>
</mat-dialog-actions>
</div>
我在这里找到了解决方案:https://github.com/angular/material2/issues/7390
.cdk-global-scrollblock {
position: initial;
width: initial;
overflow: hidden;
}
我有一个按钮可以打开 material 对话框。在打开的对话框中,后台页面滚动到顶部。关闭对话框时,页面会滚动回原来的位置。
谁可以阻止此滚动?
const dialogRef = this.dialog.open(dialogComponent, {
panelClass: config.panelClass,
width: 1100px,
height: 800px,
closeOnNavigation: true,
maxHeight: '95%',
maxWidth: '95%',
data: {
someData...
},
});
我的html
<div class="dialog dialog__content">
<div>
<div *ngIf="title" class="dialog__header">
<h1 mat-dialog-title>{{title | translate}}</h1>
</div>
<div class="dialog__closing">
<button matDialogClose>
<i class="fal fa-times-circle"></i>
</button>
</div>
</div>
<mat-dialog-content>
...some content...
</mat-dialog-content>
<mat-dialog-actions *ngIf="buttons && buttons.length > 0">
<div class="buttons">
<button>...</button>
</div>
</mat-dialog-actions>
</div>
我在这里找到了解决方案:https://github.com/angular/material2/issues/7390
.cdk-global-scrollblock {
position: initial;
width: initial;
overflow: hidden;
}