我使用MatDialogofAngular Material在末尾顯示一個文本段落和一個按鈕。在用戶向下滾動并使用 Angular / JavaScript 到達該段落的底部之前,如何保持按鈕處于禁用狀態?
uj5u.com熱心網友回復:
您可以通過使用scroll事件來做到這一點:
<mat-dialog-content (scroll)="onScroll($event)">
all your content here...
</mat-dialog-content>
<mat-dialog-actions align="end">
<button [disabled]="buttonDisabled" mat-button>OK</button>
</mat-dialog-actions>
和 TS:
buttonDisabled = true;
onScroll(ev: any) {
if (ev.target.offsetHeight ev.target.scrollTop >= ev.target.scrollHeight) {
this.buttonDisabled = false;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/417401.html
標籤:
