我有以下按钮:
<button class="kv_styleclass_0 btn btn-outline-success btn-lg"
data-bs-toggle="modal"
data-bs-target="formModal"
type="button">
Стать участником
</button>
触发以下模式对话框:
<div class="modal fade"
aria-labelledby="formModal_label"
aria-hidden="true"
id="formModal"
tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"
id="formModal_label">
Анкета участника
</h5>
<button class="btn btn-secondary btn-primary"
data-bs-dismiss="modal"
type="button">
Закрыть
</button>
</div>
<div class="modal-body">
<iframe src="..."
name="..."
style="height: 407px;"
width="650"
frameborder="0">
</iframe>
</div>
</div>
</div>
</div>
当我单击按钮时,出现以下错误:
Uncaught TypeError: this._config is undefined
_initializeBackDrop bootstrap.esm.js:2916
...
使用NPM获取Bootstrap。使用 Bootstrap v5.2.3.
我尝试通过在代码中的不同位置包含
<script>
标签来获取 Bootstrap JS。与 Popper.JS 一起。
我刚刚遇到了同样的问题,我通过在 data-bs-target 中添加 # 来解决它。修改后的代码如下所示:
<button class="kv_styleclass_0 btn btn-outline-success btn-lg"
data-bs-toggle="modal"
data-bs-target="#formModal"
type="button">
Стать участником
</button>
看起来您正在传递一个字符串,而 data-bs-target 属性需要一个 id。
编辑:我刚刚看到 CodeCaster 在评论中击败了我。哎呀!
Kamu Lupa Menambahkan # tanda pagar pada bagian data-bs-target
<button class="kv_styleclass_0 btn btn-outline-success btn-lg"
data-bs-target="formModal"
type="button">
Стать участником
</button>
在按钮标签中,您必须删除此属性:
data-bs-toggle="modal"
。然后运行你的应用程序;它会解决问题。