You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Bootstrap v5.2.3模态框触发报错:Uncaught TypeError: this._config is undefined

Bootstrap 5.2.3模态框报错Uncaught TypeError: this._config is undefined排查方案
  • 核心问题:目标选择器格式错误
    你的按钮data-bs-target属性值缺少#前缀,Bootstrap需要通过CSS选择器定位模态框元素,正确写法如下:

    <button class="kv_styleclass_0 btn btn-outline-success btn-lg" 
        data-bs-toggle="modal" 
        data-bs-target="#formModal" 
        type="button">
            Стать участником
    </button>
    

    没有#的话,Bootstrap会尝试寻找标签名为formModal的元素,而非id为formModal的模态框,导致初始化时无法正确获取目标元素,进而触发this._config未定义的错误。

  • 补充排查项

    1. 确认Bootstrap与Popper版本兼容:Bootstrap 5.2.3要求搭配Popper v2.x,执行以下命令检查版本:
      npm list @popperjs/core
      
      若版本不匹配,重新安装兼容版本:
      npm install @popperjs/core@^2.11.6
      
    2. 确认Bootstrap JS正确导入:通过NPM引入时,确保项目入口文件中正确导入(避免重复引入):
      // 完整导入Bootstrap
      import 'bootstrap';
      // 或仅导入模态框组件
      import Modal from 'bootstrap/js/dist/modal';
      

内容的提问来源于stack exchange,提问作者d1snin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 13:25:33