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

使用vue-bootstrap时出现Cannot read properties of undefined (reading 'version')错误

解决Vue3中使用Bootstrap-Vue出现"Cannot read properties of undefined (reading 'version')"错误

问题根源很明确:你安装的bootstrap-vue@2.23.1是仅适配Vue 2的版本,和你当前使用的Vue 3完全不兼容,导致代码运行时无法读取Vue相关的version属性,从而抛出错误。

下面是修复步骤:

  • 先卸载不兼容的旧依赖:
npm uninstall bootstrap-vue bootstrap
  • 安装支持Vue 3的BootstrapVue官方替代版本(BootstrapVueNext):
npm install bootstrap-vue-next bootstrap
  • 修改main.js中的代码,适配Vue 3的使用方式:
import { createApp } from 'vue'
import App from './App.vue'
import BootstrapVueNext from 'bootstrap-vue-next'

import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue-next/dist/bootstrap-vue-next.css'

const app = createApp(App)
app.use(BootstrapVueNext)
app.mount('#app')

注意:BootstrapVueNext的导入方式和旧版BootstrapVue不同,无需解构BootstrapVue,直接导入默认导出的BootstrapVueNext即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 22:40:44