javascript - 单击关闭/关闭 ng-bootstrap 模式会导致页面滚动到顶部
问题描述
我目前正在使用Ng-Boostrap 的 modal。
在模态中,我有一个反应形式。
出于某种原因,当我单击关闭按钮、提交按钮或单击模态区域外部以关闭/关闭模态时,会导致在模态关闭后页面一直滚动到顶部。
请问有没有人遇到过类似的问题,有解决办法吗?我绝对不希望它滚动到页面顶部。
这是我的 component.html 上的模态代码:
<!--begin::Modal-->
<ng-template #content let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title" id="product-allocation-settings">Product Allocation</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form [formGroup]="productAllocationForm">
<!-- other irrelevant form fields -->
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" (click)="d('Submit')">Submit</button>
</div>
</ng-template>
<!--end::Modal-->
在我的 component.ts 上,它处理模态中表单的提交。这也关闭了模态。
this.modalService.open(content, { size: 'lg', centered: true }).result.then(() => {
}, (reason) => {
if (reason === 'Submit') {
this.save();
}
});
我尝试了以下解决方案,但我似乎没有任何运气。
解决方案
推荐阅读
- sed - 如果保持空间为空,sed 是否有一种简单的方法来“h”,如果不为空,是否有“H”?
- javascript - 通过单击带有javascript的文本来复制表格元素的文本
- javascript - D3js v4 条形图中的有限水平刻度
- javascript - 如何为 jupyterlab 扩展定义图标?
- angular - 未绑定断点 - VS Code | 铬 | 角
- amazon-web-services - 更改 Redshift 表的所有权会引发“必须是超级用户才能更改所有者”
- java - 老Tomcat - Java - Ant 项目恢复
- mysql - Excel 到 MySQL 数据操作
- c++ - fstream 二进制写入/读取的意外行为,无法从文件中读取有效值
- c - 在 C 中测量实时、系统时间和用户时间