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

Webpack集成Bootstrap Table报错:Cannot set properties of undefined

Webpack环境中BootstrapTable导入失败问题排查

我在Webpack环境中尝试使用BootstrapTable库,怀疑问题出在jQuery的处理上,但无法完全确定。还未添加任何HTML表格(示例表格也未被正确处理)时,就遇到了以下错误:

Uncaught TypeError: Cannot set properties of undefined (setting 'BootstrapTable')
    at bootstrap-table.js:8541:21
    at bootstrap-table.js:4:102
    at ./node_modules/bootstrap-table/dist/bootstrap-table.js (bootstrap-table.js:5:2)
    at __webpack_require__ (bootstrap:19:1)
    at vendors-8eb79120f29fcd7dbd35.js:32570:97
    at vendors.js:4:20
    at vendors.js:4:20

我的vendor.js文件内容如下:

import jQuery from 'jquery'
window.jQuery = jQuery;
import '@popperjs/core';
import 'bootstrap';
import 'bootstrap-table/dist/bootstrap-table.js'

我也尝试过以下导入方式:

import $ from 'jquery';
window.jQuery = $;
global.jQuery = $;
window.$ = $;

我已按照官方文档进行配置,还尝试通过Webpack插件默认引入jQuery:

plugins: [
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery"
    }),

但以上操作均无效。请帮我找出无法导入该包的原因。

备注:我认为这与jQuery导入有关——在Webpack打包前从CDN引入jQuery可解决错误,但希望通过Webpack正确实现:

<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 13:35:15