angular6 - 如何防止在 Angular 材质对话框中向下滚动?
问题描述
我通过请求检索数据http
,文本被预先格式化为 HTML 文本,而且大部分时间都很长。基本上我使用以下内容:
<h2 matDialogTitle> My title</h2>
<mat-dialog-content>
<p [innerHTML]="data.displayText" ></p>
</mat-dialog-content>
<div mat-dialog-actions align="end">
<button mat-button mat-dialog-close color="primary">Close</button>
</div>
对话框的内容总是向下滚动 - 接近结尾。如何防止此功能并从一开始就显示内容?
解决方案
默认情况下,MatDialog 会将焦点设置到对话框中的第一个可聚焦组件,最终成为内容下方的按钮。您可以在通过对话框配置启动对话框时禁用此功能:
dialog.open(MyDialogComponent, {
autoFocus: false
});
推荐阅读
- java - Can't use @RequestBody with PostMapping only with GetMapping
- android - Android 更新未出现在 Play 商店中
- ios - 使用静态宽度子视图创建动态水平视图
- boost-log - 提升日志文件名的日志通配符
- docker - Docker 注册表垃圾收集器不会删除层
- vb.net - 我动态创建的 CheckBox 单击事件处理程序未触发
- android - XML - 编辑矢量图像
- vuejs2 - 在 Bootstrap-vue 中限制卡片组中的卡片数量
- python - 这给了我同样的结果!!!!!!全部 3 为什么?这里有什么问题?
- docker - 安装路径覆盖现有内容